Part Number Hot Search : 
PC0867 54HC161F D5702 0FB00 5KPA200A 121NQ TS122PTR MCF5471
Product Description
Full Text Search
 

To Download C8051F060 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  ds007-0.4-nov02 cygnal integrated products, inc. ? 2002 page 1 mixed-signal isp flash mcu family C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information analog peripherals - two 16-bit sar adcs ? 16-bit resolution ? 0.75 lsb inl,guaranteed no missing codes ? programmable throughput up to 1 msps ? operate as two single-ended or one differential con- verter ? direct memory access; data stored in ram without soft- ware overhead ? data-dependent windowed interrupt generator - 10-bit sar adc ? programmable throughput up to 200 ksps ? 8 external inputs,single-ended or differential ? built-in temperature sensor - two 12-bit dacs ? can synchronize outputs to timers for jitter-free wave- form generation - three analog comparators ? programmable hysteresis/response time - voltage reference - precision vdd monitor/brown-out detector on-chip jtag debug & boundary scan - on-chip debug circuitry facilitates full- speed,non- intrusive in-circuit/in-system debugging - provides breakpoints,single-stepping,watchpoints, stack monitor; inspect/modify memory and registers - superior performance to emulation systems using ice- chips,target pods,and sockets - ieee1149.1 compliant boundary scan - complete development kit high speed 8051 ccore - pipelined instruction architecture; executes 70% of instruction set in 1 or 2 system clocks - up to 25 mips throughput with 25 mhz clock - flexible interrupt sources memory - 4352 bytes internal data ram (4k + 256) - 64k bytes flash; in-system programmable in 512-byte sectors - external 64k byte data memory interface with multi- plexed and non-multiplexed modes (C8051F060/2) digital peripherals - 59 general purpose i/o pins (C8051F060/2) - 24 general purpose i/o pins (c8051f061/3) - bosch controller area network (can 2.0b),hardware smbus? (i 2 c? compatible),spi?,and two uart serial ports available concurrently - programmable 16-bit counter/timer array with 6 capture/compare modules - 5 general purpose 16-bit counter/timers - dedicated watch-dog timer; bi-directional reset pin clock sources - internal calibrated precision oscillator: 24.5 mhz - external oscillator: crystal,rc,c,or clock - real-time clock mode using timer 2,3,4,or pca supply voltage .......................... 2.7v to 3.6v - multiple power saving sleep and shutdown modes 100-pin tqfp and 64-pin tqfp packages available temperature range: -40c to +85c jtag 64kb isp flash 4352 b sram sanity control 16-bit 1msps adc clock circuit temp sensor analog peripherals port 0 port 1 port 2 crossbar digital i/o high-speed controller core debug circuitry 22 interrupts 8051 cpu (25mips) 10-bit 200ksps adc port 4 port 5 port 6 port 7 external memory interface 100 pin only uart0 smbus spi bus pca timer 0 timer 1 timer 2 timer 3 timer 4 uart1 can 2.0b amux vref dma interface 16-bit 1msps adc 12-bit dac voltage comparators + - + - + - 12-bit dac port 3
page 2 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n notes
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 3 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information table of contents 1. system overview .........................................................................................................19 1.1. cip-51? microcontroller core ......................................................................................23 1.1.1. fully 8051 compatible ..........................................................................................23 1.1.2. improved throughput ............................................................................................23 1.1.3. additional features................................................................................................24 1.2. on-chip memory ............................................................................................................25 1.3. jtag debug and boundary scan ...................................................................................26 1.4. programmable digital i/o and crossbar .........................................................................27 1.5. programmable counter array .........................................................................................28 1.6. controller area network.................................................................................................29 1.7. serial ports................................................................................................................ .......30 1.8. 16-bit analog to digital converters ...............................................................................31 1.9. 10-bit analog to digital converter.................................................................................32 1.10. comparators and dacs...................................................................................................33 2. absolute maximum ratings ..................................................................................34 3. global dc electrical characteristics ......................................................35 4. pinout and package definitions........................................................................36 5. 16-bit adcs (adc0 and adc1)......................................................................................45 5.1. single-ended or differential operation ..........................................................................46 5.1.1. pseudo-differential inputs .....................................................................................46 5.2. voltage reference ........................................................................................................... 47 5.3. adc modes of operation ...............................................................................................48 5.3.1. starting a conversion.............................................................................................48 5.3.2. tracking modes .....................................................................................................49 5.3.3. settling time requirements ..................................................................................51 5.4. calibration ................................................................................................................ .......61 5.5. adc0 programmable window detector.........................................................................64 6. direct memory access interface (dma0) .....................................................71 6.1. writing to the instruction buffer.....................................................................................71 6.2. dma0 instruction format...............................................................................................72 6.3. xram addressing and setup .........................................................................................72 6.4. instruction execution in mode 0 .....................................................................................73 6.5. instruction execution in mode 1 .....................................................................................74 6.6. interrupt sources ........................................................................................................... ..75 6.7. data buffer overflow warnings and errors ...................................................................75 7. 10-bit adc (adc2) .............................................................................................................8 3 7.1. analog multiplexer .........................................................................................................8 4 7.2. modes of operation.........................................................................................................85 7.2.1. starting a conversion.............................................................................................85 7.2.2. tracking modes .....................................................................................................86 7.2.3. settling time requirements ..................................................................................87 7.3. programmable window detector ....................................................................................93
page 4 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 7.3.1. window detector in single-ended mode .............................................................95 7.3.2. window detector in differential mode.................................................................96 8. dacs, 12-bit voltage mode (dac0 and dac1) ..................................................99 8.1. dac output scheduling................................................................................................100 8.1.1. update output on-demand .................................................................................100 8.1.2. update output based on timer overflow ...........................................................100 8.2. dac output scaling/justification.................................................................................100 9. voltage reference 2 (C8051F060/2).....................................................................107 10. voltage reference 2 (c8051f061/3) ....................................................................109 11. comparators................................................................................................................1 11 11.1. comparator inputs .........................................................................................................1 13 12. cip-51 microcontroller........................................................................................117 12.1. instruction set............................................................................................................ ....118 12.1.1. instruction and cpu timing................................................................................118 12.1.2. movx instruction and program memory...........................................................118 12.2. memory organization ...................................................................................................123 12.2.1. program memory .................................................................................................123 12.2.2. data memory .......................................................................................................123 12.2.3. general purpose registers ...................................................................................124 12.2.4. bit addressable locations ...................................................................................124 12.2.5. stack .................................................................................................................12 4 12.2.6. special function registers...................................................................................125 12.2.6.1. sfr paging..................................................................................................125 12.2.6.2. interrupts and sfr paging...........................................................................125 12.2.6.3. sfr page stack example ............................................................................127 12.2.7. register descriptions ...........................................................................................140 12.3. interrupt handler .......................................................................................................... .143 12.3.1. mcu interrupt sources and vectors ...................................................................143 12.3.2. external interrupts ...............................................................................................143 12.3.3. interrupt priorities................................................................................................145 12.3.4. interrupt latency..................................................................................................145 12.3.5. interrupt register descriptions ............................................................................146 12.4. power management modes ...........................................................................................152 12.4.1. idle mode .............................................................................................................152 12.4.2. stop mode............................................................................................................152 13. reset sources ..............................................................................................................15 5 13.1. power-on reset............................................................................................................. .156 13.2. power-fail reset ........................................................................................................... .156 13.3. external reset............................................................................................................. ...156 13.4. missing clock detector reset .......................................................................................157 13.5. comparator0 reset ........................................................................................................15 7 13.6. external cnvstr2 pin reset.......................................................................................157 13.7. watchdog timer reset ..................................................................................................157 13.7.1. enable/reset wdt ..............................................................................................157 13.7.2. disable wdt .......................................................................................................158
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 5 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 13.7.3. disable wdt lockout.........................................................................................158 13.7.4. setting wdt interval...........................................................................................158 14. oscillators................................................................................................................. ..161 14.1. programmable internal oscillator .................................................................................161 14.2. external oscillator drive circuit...................................................................................163 14.3. system clock selection.................................................................................................163 14.4. external crystal example..............................................................................................165 14.5. external rc example ....................................................................................................165 14.6. external capacitor example..........................................................................................165 15. flash memory ..............................................................................................................167 15.1.programming the flash memory .................................................................................167 15.2.non-volatile data storage .............................................................................................169 15.3. security options ........................................................................................................... .169 16. external data memory interface and on-chip xram.......................175 16.1. accessing xram..........................................................................................................175 16.1.1. 16-bit movx example.......................................................................................175 16.1.2. 8-bit movx example.........................................................................................175 16.2. configuring the external memory interface .................................................................176 16.3. port selection and configuration ..................................................................................176 16.4. multiplexed and non-multiplexed selection.................................................................178 16.4.1. multiplexed configuration ..................................................................................178 16.4.2. non-multiplexed configuration...........................................................................179 16.5. memory mode selection ...............................................................................................180 16.5.1. internal xram only ...........................................................................................180 16.5.2. split mode without bank select ..........................................................................180 16.5.3. split mode with bank select ...............................................................................181 16.5.4. external only .......................................................................................................181 16.6. timing .................................................................................................................... ...182 16.6.1. non-multiplexed mode........................................................................................183 16.6.1.1. 16-bit movx: emi0cf[4:2] = 101,110,or 111................................183 16.6.1.2. 8-bit movx without bank select: emi0cf[4:2] = 101 or 111............184 16.6.1.3. 8-bit movx with bank select: emi0cf[4:2] = 110. ..............................185 16.6.2. multiplexed mode................................................................................................186 16.6.2.1. 16-bit movx: emi0cf[4:2] = 001,010,or 011................................186 16.6.2.2. 8-bit movx without bank select: emi0cf[4:2] = 001 or 011............187 16.6.2.3. 8-bit movx with bank select: emi0cf[4:2] = 010. ..............................188 17. port input/output .....................................................................................................191 17.1. ports 0 through 3 and the priority crossbar decoder....................................................193 17.1.1. crossbar pin assignment and allocation ............................................................193 17.1.2. configuring the output modes of the port pins ..................................................194 17.1.3. configuring port pins as digital inputs ...............................................................195 17.1.4. weak pull-ups......................................................................................................195 17.1.5. configuring port 1 and 2 pins as analog inputs..................................................195 17.1.6. crossbar pin assignment example......................................................................196 17.2.ports 4 through 7 (C8051F060/2 only)..........................................................................207
page 6 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 17.2.1. configuring ports which are not pinned out.......................................................207 17.2.2. configuring the output modes of the port pins ..................................................207 17.2.3. configuring port pins as digital inputs ...............................................................207 17.2.4. weak pull-ups......................................................................................................207 17.2.5. external memory interface ..................................................................................208 18. controller area network (can0) ..................................................................213 18.1. bosch can controller operation .................................................................................215 18.2. can registers.............................................................................................................. .216 18.2.1. can controller protocol registers .....................................................................216 18.2.2. message object interface registers.....................................................................216 18.2.3. message handler registers..................................................................................216 18.2.4. cip-51 mcu special function registers ............................................................217 18.2.5. using can0adr,can0dath,and candatl to access can registers .217 18.2.6. can0adr autoincrement feature.....................................................................217 19. system management bus / i2c bus (smbus0) .................................................223 19.1. supporting documents ..................................................................................................224 19.2. smbus protocol............................................................................................................. 224 19.2.1. arbitration............................................................................................................2 25 19.2.2. clock low extension...........................................................................................225 19.2.3. scl low timeout ...............................................................................................225 19.2.4. scl high (smbus free) timeout.......................................................................225 19.3. smbus transfer modes.................................................................................................226 19.3.1. master transmitter mode ....................................................................................226 19.3.2. master receiver mode.........................................................................................226 19.3.3. slave transmitter mode.......................................................................................227 19.3.4. slave receiver mode ...........................................................................................227 19.4. smbus special function registers ...............................................................................228 19.4.1. control register ...................................................................................................228 19.4.2. clock rate register .............................................................................................230 19.4.3. data register........................................................................................................231 19.4.4. address register ..................................................................................................231 19.4.5. status register .....................................................................................................232 20. enhanced serial peripheral interface (spi0) .........................................235 20.1. signal descriptions........................................................................................................ 236 20.1.1. master out,slave in (mosi) ..............................................................................236 20.1.2. master in,slave out (miso) ..............................................................................236 20.1.3. serial clock (sck) ..............................................................................................236 20.1.4. slave select (nss)...............................................................................................236 20.2. spi0 master mode operation........................................................................................237 20.3. spi0 slave mode operation ..........................................................................................239 20.4. spi0 interrupt sources...................................................................................................239 20.5. serial clock timing ......................................................................................................240 20.6. spi special function registers .....................................................................................241 21. uart0 ....................................................................................................................... ...........249 21.1. uart0 operational modes ..........................................................................................250
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 7 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 21.1.1. mode 0: synchronous mode................................................................................250 21.1.2. mode 1: 8-bit uart,variable baud rate .........................................................251 21.1.3. mode 2: 9-bit uart,fixed baud rate ..............................................................252 21.1.4. mode 3: 9-bit uart,variable baud rate .........................................................253 21.2. multiprocessor communications...................................................................................254 21.2.1. configuration of a masked address ....................................................................254 21.2.2. broadcast addressing ..........................................................................................254 21.3. frame and transmission error detection......................................................................255 22. uart1 ....................................................................................................................... ...........261 22.1. enhanced baud rate generation...................................................................................262 22.2. operational modes ........................................................................................................26 3 22.2.1. 8-bit uart .........................................................................................................263 22.2.2. 9-bit uart .........................................................................................................264 22.3. multiprocessor communications...................................................................................265 23. timers...................................................................................................................... ..........271 23.1. timer 0 and timer 1......................................................................................................271 23.1.1. mode 0: 13-bit counter/timer.............................................................................271 23.1.2. mode 1: 16-bit counter/timer.............................................................................272 23.1.3. mode 2: 8-bit counter/timer with auto-reload .................................................273 23.1.4. mode 3: two 8-bit counter/timers (timer 0 only) ...........................................274 23.2. timer 2,timer 3,and timer 4 ......................................................................................279 23.2.1. configuring timer 2,3,and 4 to count down....................................................279 23.2.2. capture mode ......................................................................................................280 23.2.3. auto-reload mode ..............................................................................................281 23.2.4. toggle output mode............................................................................................281 24. programmable counter array .......................................................................287 24.1. pca counter/timer.......................................................................................................288 24.2. capture/compare modules............................................................................................289 24.2.1. edge-triggered capture mode .............................................................................290 24.2.2. software timer (compare) mode........................................................................291 24.2.3. high speed output mode ....................................................................................292 24.2.4. frequency output mode ......................................................................................293 24.2.5. 8-bit pulse width modulator mode ....................................................................294 24.2.6. 16-bit pulse width modulator mode ..................................................................295 24.3. register descriptions for pca0 ....................................................................................296 25. jtag (ieee 1149.1)............................................................................................................ 301 25.1. boundary scan.............................................................................................................. .302 25.1.1. extest instruction ............................................................................................305 25.1.2. sample instruction ...........................................................................................305 25.1.3. bypass instruction ............................................................................................305 25.1.4. idcode instruction ............................................................................................305 25.2. flash programming commands ....................................................................................306 25.3. debug support.............................................................................................................. .309
page 8 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n notes
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 9 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information list of figures 1. system overview .........................................................................................................19 figure 1.1. C8051F060/2 block diagram..............................................................................21 figure 1.2. c8051f061/3 block diagram..............................................................................22 figure 1.3. comparison of peak mcu execution speeds.....................................................23 figure 1.4. on-board clock and reset..................................................................................24 figure 1.5. on-chip memory map ........................................................................................25 figure 1.6. development/in-system debug diagram ...........................................................26 figure 1.7. digital crossbar diagram....................................................................................27 figure 1.8. pca block diagram............................................................................................28 figure 1.9. can controller overview ..................................................................................29 figure 1.10. 16-bit adc block diagram................................................................................31 figure 1.11. 10-bit adc diagram ..........................................................................................32 figure 1.12. comparator and dac diagram...........................................................................33 2. absolute maximum ratings ..................................................................................34 3. global dc electrical characteristics ......................................................35 4. pinout and package definitions........................................................................36 figure 4.1. tqfp-100 pinout diagram..................................................................................41 figure 4.2. tqfp-100 package drawing...............................................................................42 figure 4.3. tqfp-64 pinout diagram....................................................................................43 figure 4.4. tqfp-64 package drawing.................................................................................44 5. 16-bit adcs (adc0 and adc1)......................................................................................45 figure 5.1. 16-bit adc0 and adc1 control path diagram.................................................45 figure 5.2. 16-bit adc0 and adc1 data path diagram ......................................................46 figure 5.3. voltage reference block diagram......................................................................47 figure 5.4. adc track and conversion example timing ....................................................49 figure 5.5. adc0 and adc1 equivalent input circuits .......................................................51 figure 5.6. amx0sl: amux configuration register .........................................................52 figure 5.7. adc0cf: adc0 configuration register ...........................................................53 figure 5.8. adc1cf: adc1 configuration register ...........................................................54 figure 5.9. adc0cn: adc0 control register .....................................................................55 figure 5.10. adc1cn: adc1 control register .....................................................................56 figure 5.11. ref0cn: reference control register 0 .............................................................57 figure 5.12. ref1cn: reference control register 1 .............................................................57 figure 5.13. adc0h: adc0 data word msb register.........................................................58 figure 5.14. adc0l: adc0 data word lsb register ..........................................................58 figure 5.15. adc0 data word example.................................................................................59 figure 5.16. adc1h: adc1 data word msb register.........................................................60 figure 5.17. adc1l: adc1 data word lsb register ..........................................................60 figure 5.18. adc1 data word example.................................................................................60 figure 5.19. calibration coefficient locations .......................................................................61 figure 5.20. offset and gain register mapping......................................................................62 figure 5.21. offset and gain calibration block diagram .......................................................62
page 10 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 5.22. adc0cpt: adc calibration pointer register...................................................63 figure 5.23. adc0ccf: adc calibration coefficient register ............................................63 figure 5.24. adc0gth: adc0 greater-than data high byte register...............................64 figure 5.25. adc0gtl: adc0 greater-than data low byte register ................................64 figure 5.26. adc0lth: adc0 less-than data high byte register ....................................65 figure 5.27. adc0ltl: adc0 less-than data low byte register .....................................65 figure 5.28. 16-bit adc0 window interrupt example: single-ended data ..........................66 figure 5.29. 16-bit adc0 window interrupt example: differential data .............................67 6. direct memory access interface (dma0) .....................................................71 figure 6.1. dma0 block diagram ........................................................................................71 figure 6.2. dma mode 0 operation .....................................................................................73 figure 6.3. dma mode 1 operation .....................................................................................74 figure 6.4. dma0cn: dma0 control register ...................................................................76 figure 6.5. dma0cf: dma0 configuration register..........................................................77 figure 6.6. dma0ipt: dma0 instruction write address register .....................................78 figure 6.7. dma0idt: dma0 instruction write data register ..........................................78 figure 6.8. dma0bnd: dma0 instruction boundary register ..........................................79 figure 6.9. dma0isw: dma0 instruction status register..................................................79 figure 6.10. dma0dah: dma0 data address beginning msb register ...........................80 figure 6.11. dma0dal: dma0 data address beginning lsb register .............................80 figure 6.12. dma0dsh: dma0 data address pointer msb register .................................80 figure 6.13. dma0dsl: dma0 data address pointer lsb register...................................80 figure 6.14. dma0cth: dma0 repeat counter limit msb register.................................81 figure 6.15. dma0ctl: dma0 repeat counter limit lsb register ..................................81 figure 6.16. dma0csh: dma0 repeat counter msb register...........................................81 figure 6.17. dma0csl: dma0 repeat counter lsb register ............................................81 7. 10-bit adc (adc2) .............................................................................................................8 3 figure 7.1. adc2 functional block diagram .......................................................................83 figure 7.2. typical temperature sensor transfer function..................................................85 figure 7.3. 10-bit adc track and conversion example timing.........................................86 figure 7.4. adc2 equivalent input circuits .........................................................................87 figure 7.5. amx2cf: amux2 configuration register.......................................................88 figure 7.6. amx2sl: amux2 channel select register .....................................................89 figure 7.7. adc2cf: adc2 configuration register ...........................................................90 figure 7.8. adc2h: adc2 data word msb register.........................................................91 figure 7.9. adc2l: adc2 data word lsb register ..........................................................91 figure 7.10. adc2cn: adc2 control register .....................................................................92 figure 7.11. adc2gth: adc2 greater-than data high byte register...............................93 figure 7.12. adc2gtl: adc2 greater-than data low byte register ................................93 figure 7.13. adc2lth: adc2 less-than data high byte register ....................................94 figure 7.14. adc2ltl: adc2 less-than data low byte register .....................................94 figure 7.15. adc window compare example: right-justified single-ended data..............95 figure 7.16. adc window compare example: left-justified single-ended data ................95 figure 7.17. adc window compare example: right-justified differential data.................96 figure 7.18. adc window compare example: left-justified differential data ...................96
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 11 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 8. dacs, 12-bit voltage mode (dac0 and dac1) ..................................................99 figure 8.1. dac functional block diagram .........................................................................99 figure 8.2. dac0h: dac0 high byte register .................................................................101 figure 8.3. dac0l: dac0 low byte register ..................................................................101 figure 8.4. dac0cn: dac0 control register ...................................................................102 figure 8.5. dac1h: dac1 high byte register .................................................................103 figure 8.6. dac1l: dac1 low byte register ..................................................................103 figure 8.7. dac1cn: dac1 control register ...................................................................104 9. voltage reference 2 (C8051F060/2).....................................................................107 figure 9.1. voltage reference functional block diagram..................................................107 figure 9.2. ref2cn: reference control register 2 ...........................................................108 10. voltage reference 2 (c8051f061/3) ....................................................................109 figure 10.1. voltage reference functional block diagram .................................................109 figure 10.2. ref2cn: reference control register 2 ...........................................................110 11. comparators................................................................................................................1 11 figure 11.1. comparator functional block diagram ............................................................111 figure 11.2. comparator hysteresis plot...............................................................................112 figure 11.3. cptncn: comparator 0,1,and 2 control register..........................................114 figure 11.4. cptnmd: comparator mode selection register .............................................115 12. cip-51 microcontroller........................................................................................117 figure 12.1. cip-51 block diagram .....................................................................................117 figure 12.2. memory map .....................................................................................................123 figure 12.3. sfr page stack .................................................................................................126 figure 12.4. sfr page stack while using sfr page 0x0f to access port 5 .....................127 figure 12.5. sfr page stack after adc2 window comparator interrupt occurs ..............128 figure 12.6. sfr page stack upon pca interrupt occurring during an adc2 isr...........129 figure 12.7. sfr page stack upon return from pca interrupt ..........................................130 figure 12.8. sfr page stack upon return from adc2 window interrupt.........................131 figure 12.9. sfrpgcn: sfr page control register............................................................132 figure 12.10. sfrpage: sfr page register .......................................................................132 figure 12.11. sfrnext: sfr next register .......................................................................133 figure 12.12. sfrlast: sfr last register ........................................................................133 figure 12.13. sp: stack pointer .............................................................................................140 figure 12.14. dpl: data pointer low byte ..........................................................................140 figure 12.15. dph: data pointer high byte .........................................................................140 figure 12.16. psw: program status word ............................................................................141 figure 12.17. acc: accumulator..........................................................................................142 figure 12.18. b: b register ...................................................................................................142 figure 12.19. ie: interrupt enable .........................................................................................146 figure 12.20. ip: interrupt priority ........................................................................................147 figure 12.21. eie1: extended interrupt enable 1 .................................................................148 figure 12.22. eie2: extended interrupt enable 2 .................................................................149 figure 12.23. eip1: extended interrupt priority 1.................................................................150 figure 12.24. eip2: extended interrupt priority 2.................................................................151 figure 12.25. pcon: power control.....................................................................................153
page 12 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 13. reset sources ..............................................................................................................15 5 figure 13.1. reset sources ....................................................................................................155 figure 13.2. reset timing .....................................................................................................156 figure 13.3. wdtcn: watchdog timer control register ...................................................158 figure 13.4. rstsrc: reset source register.......................................................................159 14. oscillators................................................................................................................. ..161 figure 14.1. oscillator diagram ............................................................................................161 figure 14.2. oscicl: internal oscillator calibration register ............................................162 figure 14.3. oscicn: internal oscillator control register .................................................162 figure 14.4. clksel: oscillator clock selection register .................................................163 figure 14.5. oscxcn: external oscillator control register...............................................164 15. flash memory ..............................................................................................................167 figure 15.1. flash program memory map and security bytes .........................................170 figure 15.2. flacl: flash access limit .........................................................................171 figure 15.3. flscl: flash memory control ....................................................................172 figure 15.4. psctl: program store read/write control .....................................................173 16. external data memory interface and on-chip xram.......................175 figure 16.1. emi0cn: external memory interface control .................................................177 figure 16.2. emi0cf: external memory configuration .......................................................177 figure 16.3. multiplexed configuration example.................................................................178 figure 16.4. non-multiplexed configuration example .........................................................179 figure 16.5. emif operating modes.....................................................................................180 figure 16.6. emi0tc: external memory timing control ....................................................182 figure 16.7. non-multiplexed 16-bit movx timing ...........................................................183 figure 16.8. non-multiplexed 8-bit movx without bank select timing............................184 figure 16.9. non-multiplexed 8-bit movx with bank select timing.................................185 figure 16.10. multiplexed 16-bit movx timing .................................................................186 figure 16.11. multiplexed 8-bit movx without bank select timing .................................187 figure 16.12. multiplexed 8-bit movx with bank select timing.......................................188 17. port input/output .....................................................................................................191 figure 17.1. port i/o cell block diagram.............................................................................191 figure 17.2. port i/o functional block diagram ..................................................................192 figure 17.3. priority crossbar decode table ........................................................................193 figure 17.4. crossbar example: ............................................................................................197 figure 17.5. xbr0: port i/o crossbar register 0 .................................................................198 figure 17.6. xbr1: port i/o crossbar register 1 .................................................................199 figure 17.7. xbr2: port i/o crossbar register 2 .................................................................200 figure 17.8. xbr3: port i/o crossbar register 3 .................................................................201 figure 17.9. p0: port0 data register .....................................................................................202 figure 17.10. p0mdout: port0 output mode register.......................................................202 figure 17.11. p1: port1 data register ...................................................................................203 figure 17.12. p1mdin: port1 input mode register .............................................................203 figure 17.13. p1mdout: port1 output mode register.......................................................204 figure 17.14. p2: port2 data register ...................................................................................204 figure 17.15. p2mdin: port2 input mode register .............................................................205
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 13 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 17.16. p2mdout: port2 output mode register.......................................................205 figure 17.17. p3: port3 data register ...................................................................................206 figure 17.18. p3mdout: port3 output mode register.......................................................206 figure 17.19. p4: port4 data register ...................................................................................209 figure 17.20. p4mdout: port4 output mode register.......................................................209 figure 17.21. p5: port5 data register ...................................................................................210 figure 17.22. p5mdout: port5 output mode register.......................................................210 figure 17.23. p6: port6 data register ...................................................................................211 figure 17.24. p6mdout: port6 output mode register.......................................................211 figure 17.25. p7: port7 data register ...................................................................................212 figure 17.26. p7mdout: port7 output mode register.......................................................212 18. controller area network (can0) ..................................................................213 figure 18.1. can controller diagram ..................................................................................214 figure 18.2. typical can bus configuration.......................................................................214 figure 18.3. can0dath: can data access register high byte ......................................220 figure 18.4. can0datl: can data access register low byte .......................................220 figure 18.5. can0adr: can address index register .......................................................221 figure 18.6. can0cn: can control register .....................................................................221 figure 18.7. can0tst: can test register.........................................................................222 figure 18.8. can0sta: can status register .....................................................................222 19. system management bus / i2c bus (smbus0) .................................................223 figure 19.1. smbus0 block diagram ...................................................................................223 figure 19.2. typical smbus configuration ..........................................................................224 figure 19.3. smbus transaction ...........................................................................................225 figure 19.4. typical master transmitter sequence...............................................................226 figure 19.5. typical master receiver sequence ...................................................................226 figure 19.6. typical slave transmitter sequence .................................................................227 figure 19.7. typical slave receiver sequence .....................................................................227 figure 19.8. smb0cn: smbus0 control register ...............................................................229 figure 19.9. smb0cr: smbus0 clock rate register..........................................................230 figure 19.10. smb0dat: smbus0 data register ...............................................................231 figure 19.11. smb0adr: smbus0 address register..........................................................231 figure 19.12. smb0sta: smbus0 status register..............................................................232 20. enhanced serial peripheral interface (spi0) .........................................235 figure 20.1. spi block diagram............................................................................................235 figure 20.2. multiple-master mode connection diagram ....................................................238 figure 20.3. 3-wire single master and 3-wire single slave mode connection diagram ...238 figure 20.4. 4-wire single master mode and 4-wire slave mode connection diagram ....238 figure 20.5. data/clock timing diagram .............................................................................240 figure 20.6. spi0cfg: spi0 configuration register............................................................241 figure 20.7. spi0cn: spi0 control register ........................................................................242 figure 20.8. spi0ckr: spi0 clock rate register ................................................................243 figure 20.9. spi0dat: spi0 data register ..........................................................................244 figure 20.10. spi slave timing (ckpha = 0) .....................................................................245 figure 20.11. spi slave timing (ckpha = 1) .....................................................................245
page 14 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 20.12. spi master timing (ckpha = 0) ...................................................................246 figure 20.13. spi master timing (ckpha = 1) ...................................................................246 21. uart0 ....................................................................................................................... ...........249 figure 21.1. uart0 block diagram.....................................................................................249 figure 21.2. uart0 mode 0 timing diagram .....................................................................250 figure 21.3. uart0 mode 0 interconnect............................................................................250 figure 21.4. uart0 mode 1 timing diagram .....................................................................251 figure 21.5. uart0 modes 2 and 3 timing diagram..........................................................252 figure 21.6. uart0 modes 1,2,and 3 interconnect diagram ............................................253 figure 21.7. uart multi-processor mode interconnect diagram .......................................255 figure 21.8. scon0: uart0 control register....................................................................257 figure 21.9. ssta0: uart0 status and clock selection register ......................................258 figure 21.10. sbuf0: uart0 data buffer register............................................................259 figure 21.11. saddr0: uart0 slave address register ....................................................259 figure 21.12. saden0: uart0 slave address enable register ........................................259 22. uart1 ....................................................................................................................... ...........261 figure 22.1. uart1 block diagram.....................................................................................261 figure 22.2. uart1 baud rate logic ..................................................................................262 figure 22.3. uart interconnect diagram ............................................................................263 figure 22.4. 8-bit uart timing diagram ...........................................................................263 figure 22.5. 9-bit uart timing diagram ...........................................................................264 figure 22.6. uart multi-processor mode interconnect diagram .......................................265 figure 22.7. scon1: serial port 1 control register.............................................................266 figure 22.8. sbuf1: serial (uart1) port data buffer register .........................................267 23. timers...................................................................................................................... ..........271 figure 23.1. t0 mode 0 block diagram................................................................................272 figure 23.2. t0 mode 2 block diagram................................................................................273 figure 23.3. t0 mode 3 block diagram................................................................................274 figure 23.4. tcon: timer control register.........................................................................275 figure 23.5. tmod: timer mode register...........................................................................276 figure 23.6. ckcon: clock control register......................................................................277 figure 23.7. tl0: timer 0 low byte ....................................................................................278 figure 23.8. tl1: timer 1 low byte ....................................................................................278 figure 23.9. th0: timer 0 high byte ...................................................................................278 figure 23.10. th1: timer 1 high byte .................................................................................278 figure 23.11. t2,3,and 4 capture mode block diagram ....................................................280 figure 23.12. t2,3,and 4 auto-reload mode block diagram..............................................281 figure 23.13. tmrncn: timer 2,3,and 4 control registers ..............................................283 figure 23.14. tmrncf: timer 2,3,and 4 configuration registers ....................................284 figure 23.15. rcapnl: timer 2,3,and 4 capture register low byte................................285 figure 23.16. rcapnh: timer 2,3,and 4 capture register high byte ..............................285 figure 23.17. tmrnl: timer 2,3,and 4 low byte .............................................................285 figure 23.18. tmrnh timer 2,3,and 4 high byte .............................................................286 24. programmable counter array .......................................................................287 figure 24.1. pca block diagram..........................................................................................287
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 15 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 24.2. pca counter/timer block diagram .................................................................288 figure 24.3. pca interrupt block diagram...........................................................................289 figure 24.4. pca capture mode diagram ............................................................................290 figure 24.5. pca software timer mode diagram................................................................291 figure 24.6. pca high speed output mode diagram ..........................................................292 figure 24.7. pca frequency output mode ...........................................................................293 figure 24.8. pca 8-bit pwm mode diagram ......................................................................294 figure 24.9. pca 16-bit pwm mode ...................................................................................295 figure 24.10. pca0cn: pca control register ....................................................................296 figure 24.11. pca0md: pca0 mode register ....................................................................297 figure 24.12. pca0cpmn: pca0 capture/compare mode registers .................................298 figure 24.13. pca0l: pca0 counter/timer low byte .......................................................299 figure 24.14. pca0h: pca0 counter/timer high byte ......................................................299 figure 24.15. pca0cpln: pca0 capture module low byte ..............................................300 figure 24.16. pca0cphn: pca0 capture module high byte .............................................300 25. jtag (ieee 1149.1)............................................................................................................ 301 figure 25.1. ir: jtag instruction register ..........................................................................301 figure 25.2. deviceid: jtag device id register ............................................................305 figure 25.3. flashcon: jtag flash control register.....................................................307 figure 25.4. flashdat: jtag flash data register..........................................................308 figure 25.5. flashadr: jtag flash address register ....................................................308
page 16 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n notes
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 17 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information list of tables 1. system overview ........................................................................................................19 table 1.1. product selection guide .......................................................................................20 2. absolute maximum ratings .................................................................................34 table 2.1. absolute maximum ratings* ...............................................................................34 3. global dc electrical characteristics .....................................................35 table 3.1. global dc electrical characteristics ....................................................................35 4. pinout and package definitions .......................................................................36 table 4.1. pin definitions ......................................................................................................36 5. 16-bit adcs (adc0 and adc1) .....................................................................................45 table 5.1. conversion timing (tconv) ..................................................................................50 table 5.2. 16-bit adc0 and adc1 electrical characteristics .............................................68 table 5.3. voltage reference 0 and 1 electrical characteristics ...........................................69 6. direct memory access interface (dma0) ....................................................71 table 6.1. dma0 instruction set ...........................................................................................72 7. 10-bit adc (adc2) ............................................................................................................83 table 7.1. adc2 electrical characteristics ...........................................................................97 8. dacs, 12-bit voltage mode (dac0 and dac1) .................................................99 table 8.1. dac electrical characteristics ...........................................................................105 9. voltage reference 2 (C8051F060/2) ....................................................................107 table 9.1. voltage reference electrical characteristics .....................................................108 10. voltage reference 2 (c8051f061/3) ...................................................................109 table 10.1.voltage reference electrical characteristics .....................................................110 11. comparators ...............................................................................................................11 1 table 11.1.comparator electrical characteristics ................................................................116 12. cip-51 microcontroller .......................................................................................117 table 12.1.cip-51 instruction set summary ........................................................................119 table 12.2.special function register (sfr) memory map .................................................134 table 12.3.special function registers .................................................................................135 table 12.4.interrupt summary ..............................................................................................144 13. reset sources .............................................................................................................155 table 13.1.reset electrical characteristics ..........................................................................160 14. oscillators ................................................................................................................. .161 table 14.1.internal oscillator electrical characteristics ......................................................163 15. flash memory .............................................................................................................167 table 15.1.flash electrical characteristics .......................................................................168 16. external data memory interface and on-chip xram ......................175 table 16.1.ac parameters for external memory interface ..................................................189 17. port input/output ....................................................................................................191 table 17.1.port i/o dc electrical characteristics ................................................................191 18. controller area network (can0) .................................................................213 table 18.1.can register index and reset values ...............................................................217 19. system management bus / i2c bus (smbus0) ................................................223
page 18 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n table 19.1.smb0sta status codes and states ...................................................................233 20. enhanced serial peripheral interface (spi0) ........................................235 table 20.1.spi slave timing parameters .............................................................................247 21. uart0 ....................................................................................................................... ..........249 table 21.1.uart0 modes ....................................................................................................250 table 21.2.oscillator frequencies for standard baud rates ................................................256 22. uart1 ....................................................................................................................... ..........261 table 22.1.timer settings for standard baud rates using the internal oscillator ............268 table 22.2.timer settings for standard baud rates using an external oscillator ..............268 table 22.3.timer settings for standard baud rates using an external oscillator ..............269 table 22.4.timer settings for standard baud rates using an external oscillator ..............269 table 22.5.timer settings for standard baud rates using an external oscillator ..............270 table 22.6.timer settings for standard baud rates using an external oscillator ..............270 23. timers ...................................................................................................................... .........271 24. programmable counter array ......................................................................287 table 24.1.pca timebase input options .............................................................................288 table 24.2.pca0cpm register settings for pca capture/compare modules ...................289 25. jtag (ieee 1149.1) ...........................................................................................................3 01 table 25.1.boundary data register bit definitions (C8051F060/2) ...................................302 table 25.2.boundary data register bit definitions (c8051f061/3) ...................................304
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 19 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 1. system overview the c8051f06x family of devices are fully integrated mixed-signal system-on-a-chip mcus with 59 digital i/o pins (C8051F060/2) or 24 digital i/o pins (c8051f061/3),and an integrated can 2.0b controller. highlighted features are listed below; refer to table 1.1 for specific product feature selection. ? high-speed pipelined 8051-compatible cip-51 microcontroller core (up to 25 mips) ? two 16-bit 1 msps adcs with a direct memory access controller ? controller area network (can 2.0b) controller with 32 message objects,each with its own indentifier mask ? in-system,full-speed,non-intrusive debug interface (on-chip) ? 10-bit 200 ksps adc with pga and 8-channel analog multiplexer ? two 12-bit dacs with programmable update scheduling ? 64k bytes of in-system programmable flash memory ? 4352 (4096 + 256) bytes of on-chip ram ? external data memory interface with 64k byte address space ? spi,smbus/i 2 c,and (2) uart serial interfaces implemented in hardware ? five general purpose 16-bit timers ? programmable counter/timer array with six capture/compare modules ? on-chip watchdog timer,vdd monitor,and temperature sensor with on-chip vdd monitor,watchdog timer,and clock oscillator,the c8051f06x family of devices are truly stand- alone system-on-a-chip solutions. all analog and digital peripherals are enabled/disabled and configured by user firmware. the flash memory can be reprogrammed even in-circuit,providing non-volatile data storage,and also allowing field upgrades of the 8051 firmware. on-board jtag debug circuitry allows non-intrusive (uses no on-chip resources),full speed,in-circuit debugging using the production mcu installed in the final application. this debug system supports inspection and modification of memory and registers,setting breakpoints,watchpoints,single stepping,run and halt commands. all analog and digital peripherals are fully functional while debugging using jtag. each mcu is specified for 2.7 v to 3.6 v operation over the industrial temperature range (-45c to +85c). the C8051F060/2 are available in a 100-pin tqfp package and the c8051f061/3 are available in a 64-pin tqfp package (see block diagrams in figure 1.1 and figure 1.2).
page 20 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n table 1.1. product selection guide mips (peak) flash memory ram external memory interface smbus/i 2 candspi can uarts timers (16-bit) programmable counter array digitalporti/os 16-bit 1 msps adc typical inl (lsbs) 10-bit 200 ksps adc inputs voltage reference temperature sensor dac resolution (bits) dac outputs analog comparators package C8051F060 25 64k 4352 !!! 25 ! 59 0.75 8 !! 12 2 3 100tqfp c8051f061 25 64k 4352 - !! 25 ! 24 0.75 8 !! 12 2 3 64tqfp c8051f062 25 64k 4352 !!! 25 ! 59 1.5 8 !! 12 2 3 100tqfp c8051f063 25 64k 4352 - !! 25 ! 24 1.5 8 !! 12 2 3 64tqfp
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 21 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information p0, p1, p2, p3 latches jtag logic tck tms tdi tdo uart1 smbus spi bus pca 64kbyte flash 256 byte ram vdd monitor sfr bus 8 0 5 1 c o r e timers 0, 1, 2,3,4 p0 drv c r o s s b a r reset /rst xtal1 xtal2 external oscillator circuit system clock trimmed internal oscillator digital power analog power debug hw boundary scan 4kbyte ram p2.0 p2.7 p1.0/ain2.0 p1.7/ain2.7 p0.0 p0.7 p1 drv p2 drv data bus address bus bus control dac0 dac0 (12-bit) vref vref uart0 p3.0 p3.7 p3 drv adc2 200ksps (10-bit) a m u x monen wdt vref2 vrefd p4 latch p7 latch p5 latch p6 latch p7.0 p7.7 p7 drv p5.0 p5.7 p5 drv p6.0 p6.7 p6 drv p4 drv p4.5 p4.6 p4.7 external data memory bus addr[7:0] addr[15:8] ctrl latch data latch cantx canrx can 2.0b adc0 1msps (16-bit) vrgnd0 a d c 0 d a t a a d c 1 d a t a - + d i f f dma interface dac1 temp sensor emif control vdd vdd vdd dgnd dgnd dgnd av+ agnd vref0 agnd av+ vrgnd1 vref1 agnd avdd ain0 ain0g vbgap0 cnvstr0 adc1 1msps (16-bit) agnd av+ ain1 ain1g vbgap1 cnvstr1 32x136 canram p2.7 p2.6 + - cp0 p2.3 p2.2 + - cp1 p2.5 p2.4 + - cp2 figure 1.1. C8051F060/2 block diagram
page 22 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n p3 drv p0, p1, p2, p3 latches jtag logic tck tms tdi tdo uart1 smbus spi bus pca 64kbyte flash 256 byte ram vdd monitor sfr bus 8 0 5 1 c o r e timers 0, 1, 2,3,4 p0 drv c r o s s b a r reset /rst xtal1 xtal2 external oscillator circuit system clock trimmed internal oscillator digital power analog power debug hw boundary scan 4kbyte ram p2.0 p2.7 p1.0/ain2.0 p1.7/ain2.7 p0.0 p0.7 p1 drv p2 drv dac0 dac0 (12-bit) vref vref uart0 adc2 200ksps (10-bit) a m u x monen wdt vref2 vref2 external data memory bus cantx canrx can 2.0b adc0 1msps (16-bit) vrgnd0 a d c 0 d a t a a d c 1 d a t a - + d i f f dma interface dac1 temp sensor emif control vdd vdd vdd dgnd dgnd dgnd av+ agnd vref0 agnd av+ vrgnd1 vref1 agnd avdd ain0 ain0g vbgap0 cnvstr0 adc1 1msps (16-bit) agnd av+ ain1 ain1g vbgap1 cnvstr1 32x136 canram p2.7 p2.6 + - cp0 p2.3 p2.2 + - cp1 p2.5 p2.4 + - cp2 p4 latch p7 latch p5 latch p6 latch p7 drv p5 drv p6 drv p4 drv addr[7:0] addr[15:8] ctrl latch data latch figure 1.2. c8051f061/3 block diagram
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 23 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 1.1. cip-51? microcontroller core 1.1.1. fully 8051 compatible the c8051f06x family of devices utilizes cygnal's proprietary cip-51 microcontroller core. the cip-51 is fully compatible with the mcs-51? instruction set; standard 803x/805x assemblers and compilers can be used to develop software. the core has all the peripherals included with a standard 8052,including five 16-bit counter/timers,two full-duplex uarts,256 bytes of internal ram,128 byte special function register (sfr) address space,and bit- addressable i/o ports. 1.1.2. improved throughput the cip-51 employs a pipelined architecture that greatly increases its instruction throughput over the standard 8051 architecture. in a standard 8051,all instructions except for mul and div take 12 or 24 system clock cycles to exe- cute with a maximum system clock of 12-to-24 mhz. by contrast,the cip-51 core executes 70% of its instructions in one or two system clock cycles,with only four instructions taking more than four system clock cycles. the cip-51 has a total of 109 instructions. the table below shows the total number of instructions that require each execution time. with the cip-51's maximum system clock at 25 mhz,it has a peak throughput of 25 mips. figure 1.3 shows a com- parison of peak throughputs of various 8-bit microcontroller cores with their maximum system clocks. clocks to execute 1 22/333/444/55 8 number of instructions 265051473121 5 10 15 20 aduc812 8051 (16mhz clk) philips 80c51 (33mhz clk) microchip pic17c75x (33mhz clk) cygnal cip-51 (25mhz clk) mips 25 figure 1.3. comparison of peak mcu execution speeds
page 24 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 1.1.3. additional features the c8051f06x mcu family includes several key enhancements to the cip-51 core and peripherals to improve over- all performance and ease of use in end applications. the extended interrupt handler provides 22 interrupt sources into the cip-51 (as opposed to 7 for the standard 8051), allowing the numerous analog and digital peripherals to interrupt the controller. an interrupt driven system requires less intervention by the mcu,giving it more effective throughput. the extra interrupt sources are very useful when building multi-tasking,real-time systems. there are up to seven reset sources for the mcu: an on-board vdd monitor,a watchdog timer,a missing clock detector,a voltage level detection from comparator0,a forced software reset,the cnvstr2 input pin,and the /rst pin. the /rst pin is bi-directional,accommodating an external reset,or allowing the internally generated por to be output on the /rst pin. each reset source except for the vdd monitor and reset input pin may be disabled by the user in software; the vdd monitor is enabled/disabled via the monen pin. the watchdog timer may be perma- nently enabled in software after a power-on reset during mcu initialization. the mcu has an internal,stand alone clock generator which is used by default as the system clock after any reset. if desired,the clock source may be switched on the fly to the external oscillator,which can use a crystal,ceramic reso- nator,capacitor,rc,or external clock source to generate the system clock. this can be extremely useful in low power applications,allowing the mcu to run from a slow (power saving) external crystal source,while periodically switch- ing to the fast (up to 25 mhz) internal oscillator as needed. wdt xtal1 xtal2 osc internal clock generator system clock cip-51 microcontroller core missing clock detector (one- shot) wdt strobe software reset extended interrupt handler clock select /rst + - vdd supply reset timeout (wired-or) system reset supply monitor pre reset funnel + - cp0+ comparator0 cp0- (port i/o) crossbar cnvstr2 (cnvstr reset enable) (cp0 reset enable) en wdt enable en mcd enable (wired-or) vdd monitor reset enable figure 1.4. on-board clock and reset
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 25 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 1.2. on-chip memory the cip-51 has a standard 8051 program and data address configuration. it includes 256 bytes of data ram,with the upper 128 bytes dual-mapped. indirect addressing accesses the upper 128 bytes of general purpose ram,and direct addressing accesses the 128 byte sfr address space. the cip-51 sfr address space contains up to 256 sfr pages . in this way,the cip-51 mcu can accommodate the many sfrs required to control and configure the various periph- erals featured on the device. the lower 128 bytes of ram are accessible via direct and indirect addressing. the first 32 bytes are addressable as four banks of general purpose registers,and the next 16 bytes can be byte addressable or bit addressable. the cip-51 in the C8051F060/1/2/3 mcus additionally has an on-chip 4k byte ram block. the on-chip 4k byte block can be addressed over the entire 64k external data memory address range (overlapping 4k boundaries). the C8051F060/2 also have an external memory interface (emif) for accessing off-chip data memory or memory- mapped peripherals. external data memory address space can be mapped to on-chip memory only,off-chip memory only,or a combination of the two (addresses up to 4k directed to on-chip,above 4k directed to emif). the emif is also configurable for multiplexed or non-multiplexed address/data lines. the mcus program memory consists of 64k bytes of flash. this memory may be reprogrammed in-system in 512 byte sectors,and requires no special off-chip programming voltage. the 1024 bytes from addresses 0xfc00 to 0xffff are reserved. there is also a single 128 byte sector at address 0x10000 to 0x1007f,which may be used by software. see figure 1.5 for the mcu system memory map. program/data memory (flash) (direct and indirect addressing) 0x00 0x7f upper 128 ram (indirect addressing only) 0x80 0xff special function registers (direct addressing only) data memory (ram) general purpose registers 0x1f 0x20 0x2f bit addressable lower 128 ram (direct and indirect addressing) 0x30 internal data address space external data address space xram - 4096 bytes (accessable using movx instruction) 0x0000 0x0fff off-chip xram space (C8051F060/2 only) 0x1000 0xffff flash (in-system programmable in 512 byte sectors) 0x0000 0xffff reserved 0xfc00 0xfbff scrachpad memory (data only) 0x1007f 0x10000 up to 256 sfr pages 1 3 0 2 figure 1.5. on-chip memory map
page 26 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 1.3. jtag debug and boundary scan the c8051f06x family has on-chip jtag boundary scan and debug circuitry that provides non-intrusive, full speed, in-circuit debugging using the production part installed in the end application ,via the four-pin jtag interface. the jtag port is fully compliant to ieee 1149.1,providing full boundary scan for test and manufacturing purposes. cygnal's debugging system supports inspection and modification of memory and registers,breakpoints,watchpoints, a stack monitor,and single stepping. no additional target ram,program memory,timers,or communications chan- nels are required. all the digital and analog peripherals are functional and work correctly while debugging. all the peripherals (except for the adcs and smbus) are stalled when the mcu is halted,during single stepping,or at a breakpoint in order to keep them synchronized with instruction execution. the C8051F060dk development kit provides all the hardware and software necessary to develop application code and perform in-circuit debugging with the c8051f06x mcus. the kit includes software with a developer's studio and debugger,an integrated 8051 assembler,and an rs-232 to jtag serial adapter. it also has a target application board with the associated mcu installed,plus the rs-232 and jtag cables,and wall-mount power supply. the develop- ment kit requires a windows 95/98/nt/me computer with one available rs-232 serial port. as shown in figure 1.6, the pc is connected via rs-232 to the serial adapter. a six-inch ribbon cable connects the serial adapter to the user's application board,picking up the four jtag pins and vdd and gnd. the serial adapter takes its power from the application board. for applications where there is not sufficient power available from the target system,the pro- vided power supply can be connected directly to the serial adapter. cygnals debug environment is a vastly superior configuration for developing and debugging embedded applications compared to standard mcu emulators,which use on-board "ice chips" and target cables and require the mcu in the application board to be socketed. cygnal's debug environment both increases ease of use and preserves the perfor- mance of the precision,on-chip analog peripherals. target pcb rs-232 serial adapter c8051 f060 vdd gnd jtag(x4),vdd,gnd windows 95/98/nt cygnal integrated development environment figure 1.6. development/in-system debug diagram
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 27 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 1.4. programmable digital i/o and crossbar three standard 8051 ports (0,1,and 2) are available on the mcus. the C8051F060/2 have 4 additional 8-bit ports (3, 5,6,and 7),and a 3-bit port (port 4) for a total of 59 general-purpose i/o pins. the ports behave like the standard 8051 with a few enhancements. each port pin can be configured as either a push-pull or open-drain output. also,the "weak pull-ups" which are nor- mally fixed on an 8051 can be globally disabled,providing additional power saving capabilities for low-power appli- cations. perhaps the most unique enhancement is the digital crossbar. this is a large digital switching network that allows mapping of internal digital system resources to port i/o pins on p0,p1,p2,and p3. (see figure 1.7) unlike micro- controllers with standard multiplexed digital i/o ports,all combinations of functions are supported with all package options offered. the on-chip counter/timers,serial buses,hw interrupts,adc2 start of conversion input,comparator outputs,and other digital signals in the controller can be configured to appear on the port i/o pins specified in the crossbar con- trol registers. this allows the user to select the exact mix of general purpose port i/o and digital resources needed for the particular application. external pins digital crossbar priority decoder smbus 2 spi 4 uart0 2 pca 2 t0, t1, t2, t2ex, t3, t3ex, t4,t4ex, /int0, /int1 p1.0 p1.7 p2.0 p2.7 p0.0 p0.7 highest priority lowest priority 8 8 comptr. outputs (internal digital signals) highest priority lowest priority uart1 6 2 p3.0 p3.7 8 8 p0mdout, p1mdout, p2mdout, p3mdout registers xbr0, xbr1, xbr2, xbr3 p1mdin, p2mdin, p3mdin registers p1 i/o cells p3 i/o cells p0 i/o cells p2 i/o cells 8 port latches p0 p1 p2 8 8 8 p3 8 (p2.0-p2.7) (p1.0-p1.7) (p0.0-p0.7) (p3.0-p3.7) to adc2 input to comparators /sysclk cnvstr2 C8051F060/2 only figure 1.7. digital crossbar diagram
page 28 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 1.5. programmable counter array the c8051f06x mcu family includes an on-board programmable counter/timer array (pca) in addition to the five 16-bit general purpose counter/timers. the pca consists of a dedicated 16-bit counter/timer time base with 6 pro- grammable capture/compare modules. the timebase is clocked from one of six sources: the system clock divided by 12,the system clock divided by 4,timer 0 overflow,an external clock input (eci pin),the system clock,or the external oscillator source divided by 8. each capture/compare module can be configured to operate in one of six modes: edge-triggered capture,software timer,high speed output,frequency output,8-bit pulse width modulator,or 16-bit pulse width modulator. the pca capture/compare module i/o and external clock input are routed to the mcu port i/o via the digital cross- bar. capture/compare module 1 capture/compare module 0 capture/compare module 2 capture/compare module 3 cex1 eci crossbar cex2 cex3 cex0 port i/o 16-bit counter/timer pca clock mux sysclk/12 sysclk/4 timer 0 overflow eci sysclk external clock/8 capture/compare module 4 cex4 capture/compare module 5 cex5 figure 1.8. pca block diagram
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 29 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 1.6. controller area network the c8051f06x family of devices feature a controller area network (can) controller that implements serial com- munication using the can protocol. the can controller facilitates communication on a can network in accordance with the bosch specification 2.0a (basic can) and 2.0b (full can). the can controller consists of a can core, message ram (separate from the c8051 ram),a message handler state machine,and control registers. the can controller can operate at bit rates up to 1 mbit/second. cygnal can has 32 message objects each having its own identifier mask used for acceptance filtering of received messages. incoming data,message objects and identifier masks are stored in the can message ram. all protocol functions for transmission of data and acceptance filtering is performed by the can controller and not by the c8051 mcu. in this way,minimal cpu bandwidth is used for can communication. the c8051 configures the can controller,accesses received data,and passes data for trans- mission via special function registers (sfr) in the c8051. message handler registers message ram (32 message objects) can core tx rx can controller c 8 0 5 1 m c u interrupt s f r 's cantx canrx C8051F060/1/2/3 figure 1.9. cancontroller overview
page 30 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 1.7. serial ports the c8051f06x mcu family includes two enhanced full-duplex uarts,an enhanced spi bus,and smbus/i 2 c. each of the serial buses is fully implemented in hardware and makes extensive use of the cip-51's interrupts,thus requiring very little intervention by the cpu. the serial buses do not "share" resources such as timers,interrupts,or port i/o,so any or all of the serial buses may be used together with any other.
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 31 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 1.8. 16-bit analog to digital converters the C8051F060/1/2/3 devices have two on-chip 16-bit sar adcs (adc0 and adc1),which can be used indepen- dently in single-ended mode,or together in differential mode. adc0 and adc1 can directly access on-chip or exter- nal ram,using the dma interface. with a maximum throughput of 1 msps,the adcs offer 16 bit performance with two available linearity grades. adc0 and adc1 each have the capability to use dedicated,on-chip voltage reference circuitry or an external voltage reference source. the adcs are under full control of the cip-51 microcontroller via the associated special function registers. the system controller can also put the adcs into shutdown mode to save power. conversions can be started in four ways; a software command,an overflow of timer 2,an overflow of timer 3,or an external signal input. this flexibility allows the start of conversion to be triggered by software events,external hw signals,or a periodic timer overflow signal. the two adcs can operate independently,or be synchronized to perform conversions at the same time. conversion completions are indicated by status bits,and can generate interrupts. the resulting 16-bit data words are latched into sfrs upon completion of a conversion. a dma interface is also pro- vided,which can gather conversions from the adcs,and directly store them to on-chip or external ram. adc0 also contains window compare registers,which can be configured to interrupt the controller when adc0 data is within or outside of a specified range. adc0 can monitor a key voltage continuously in background mode,and not interrupt the controller unless the converted data is within the specified window. ain0g ref ain0 start conversion timer 3 overflow timer 2 overflow writetoad1busy cnvstr1 16-bit sar adc0 (dc, -0.2 to 0.6 v) ain1g ref ain1 start conversion 16-bit sar adc1 (dc, -0.2 to 0.6 v) writetoad0busy timer 3 overflow timer 2 overflow write to ad0busy cnvstr0 configuration and control registers dma interface adc0 window compare logic 16 adc data registers 16 figure 1.10. 16-bit adc block diagram
page 32 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 1.9. 10-bit analog to digital converter the C8051F060/1/2/3 devices have an on-board 10-bit sar adc (adc2) with a 9-channel input multiplexer and programmable gain amplifier. this adc features a 200 ksps maximum throughput and true 10-bit performance with an inl of 1lsb. eight input pins are available for measurement and can be programmed as single-ended or differ- ential inputs. additionally,the on-chip temperature sensor can be used as an input to the adc. the adc is under full control of the cip-51 microcontroller via the special function registers. the adc2 voltage reference is selected between the analog power supply (av+) and the external vref2 pin. user software may put adc2 into shutdown mode to save power. a flexible conversion scheduling system allows adc2 conversions to be initiated by software commands,timer overflows,or an external input signal. conversion completions are indicated by a status bit and an interrupt (if enabled),and the resulting 10-bit data word is latched into two sfr locations upon completion. adc2 also contains window compare registers,which can be configured to interrupt the controller when adc2 data is within or outside of a specified range. adc2 can monitor a key voltage continuously in background mode,and not interrupt the controller unless the converted data is within the specified window. 10 9-to-1 amux ain2.0 ain2.1 ain2.2 ain2.3 ain2.4 ain2.5 ain2.6 ain2.7 configuration and control registers analog multiplexer 10-bit sar adc start conversion timer 3 overflow timer 2 overflow writetoad2busy cnvstr2 input adc data registers conversion complete interrupt vref2 pin av+ vref single-ended or differential measurement temp sensor agnd adc2 window compare logic 10 figure 1.11. 10-bit adc diagram
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 33 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 1.10. comparators and dacs each C8051F060/1/2/3 mcu has two 12-bit dacs and three comparators on chip. the mcu data and control inter- face to each comparator and dac is via the special function registers. the mcu can place any dac or comparator in low power shutdown mode. the comparators have software programmable hysteresis and response time. each comparator can generate an inter- rupt on its rising edge,falling edge,or both; these interrupts are capable of waking up the mcu from sleep mode. the comparators' output state can also be polled in software. the comparator outputs can be programmed to appear on the port i/o pins via the crossbar. the dacs are voltage output mode and include a flexible output scheduling mechanism. this scheduling mechanism allows dac output updates to be forced by a software write or a timer 2,3,or 4 overflow. the dac voltage refer- ence is supplied via the dedicated vrefd input pin on C8051F060/2 devices or via the vref2 pin on c8051f061/3 devices,which is shared with adc2. the dacs are especially useful as references for the comparators or offsets for the differential inputs of the adcs. + - cpn+ cpn- dac0 dac1 vref vref cip-51 and interrupt handler cpn dac0 dac1 cpn output (port i/o) sfr's (data and cntrl) crossbar 3 comparators comparator inputs port 2.[7:2] figure 1.12. comparator and dac diagram
page 34 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 2. absolute maximum ratings table 2.1. absolute maximum ratings * parameter conditions min typ max units ambient temperature under bias -55 125 c storage temperature -65 150 c voltage on any pin (except vdd,av+,avdd,and port 0) with respect to dgnd -0.3 vdd + 0.3 v voltage on any port 0 pin with respect to dgnd. -0.3 5.8 v voltage on vdd,av+,or avdd with respect to dgnd -0.3 4.2 v maximum total current through vdd,av+,avdd, dgnd,and agnd 800 ma maximum output current sunk by any port pin 100 ma maximum output current sunk by any other i/o pin 50 ma maximum output current sourced by any port pin 100 ma maximum output current sourced by any other i/o pin 50 ma * stresses above those listed under absolute maximum ratings may cause permanent damage to the device. this is a stress rating only and functional operation of the devices at those or any other conditions above those indicated in the operation listings of this specification is not implied. exposure to maximum rating conditions for extended periods may affect device reliability.
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 35 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 3. global dc electrical characteristics table 3.1. global dc electrical characteristics -40c to +85c,25 mhz system clock unless otherwise specified. parameter conditions min typ max units analog supply voltage (av+, avdd) (note 1) 2.7 3.0 3.6 v analog supply current internal ref,adc,dac,com- parators all active tbd tbd ma analog supply current with ana- log sub-systems inactive internal ref,adc,dac,com- parators all disabled,oscillator disabled tbd tbd ma analog-to-digital supply delta (|vdd - av+| or |vdd - avdd|) 0.5 v digital supply voltage (vdd) 2.7 3.0 3.6 v digital supply current with cpu active vdd=2.7 v,clock=25 mhz vdd=2.7 v,clock=1 mhz vdd=2.7 v,clock=32 khz 18 0.7 tbd ma ma a digital supply current with cpu inactive (not accessing flash) vdd=2.7 v,clock=25 mhz vdd=2.7 v,clock=1 mhz vdd=2.7 v,clock=32 khz 5 0.2 10 ma ma a digital supply current (shut- down) oscillator not running 0.2 a digital supply ram data reten- tion voltage 1.5 v specified operating temperature range -40 +85 c note 1: analog supply av+ must be greater than 1 v for vdd monitor to operate.
page 36 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 4. pinout and package definitions table 4.1. pin definitions name pin numbers type description f060 f061 f062 f063 vdd 37,64, 90 26,40, 55 digital supply voltage. must be tied to +2.7 to +3.6 v. dgnd 38,63, 89 27,39, 54 digital ground. must be tied to ground. av+ 11,16, 24 7,10, 18 analog supply voltage. must be tied to +2.7 to +3.6 v. avdd 13 23 analog supply voltage. must be tied to +2.7 to +3.6 v. agnd 10,14, 17,23 6,11, 19,22 analog ground. must be tied to ground. tms 96 52 d in jtag test mode select with internal pull-up. tck 97 53 d in jtag test clock with internal pull-up. tdi 98 56 d in jtag test data input with internal pull-up. tdi is latched on the rising edge of tck. tdo 99 57 d out jtag test data output with internal pull-up. data is shifted out on tdo on the falling edge of tck. tdo output is a tri-state driver. /rst 100 58 d i/o device reset. open-drain output of internal vdd monitor. is driven low when vdd is <2.7 v and monen is high. an external source can initiate a system reset by driving this pin low. xtal1 26 20 a in crystal input. this pin is the return for the internal oscillator circuit for a crystal or ceramic resonator. for a precision internal clock, connect a crystal or ceramic resonator from xtal1 to xtal2. if overdriven by an external cmos clock,this becomes the system clock. xtal2 27 21 a out crystal output. this pin is the excitation driver for a crystal or ceramic resonator. monen 28 63 d in vdd monitor enable. when tied high,this pin enables the internal vdd monitor,which forces a system reset when vdd is < 2.7 v. when tied low,the internal vdd monitor is disabled. vref 4 61 a out bandgap voltage reference output for adc2,dac0,and dac1. vref0 21 15 a i/o bandgap voltage reference output for adc0. adc0 voltage reference input. vrgnd0 20 14 a in adc0 voltage reference ground.
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 37 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information vbgap0 22 16 a out adc0 bandgap bypass pin. vref1 6 2 a i/o bandgap voltage reference output for adc1. adc1 voltage reference input. vrgnd1 7 3 a in adc1 voltage reference ground. vbgap1 5 1 a out adc1 bandgap bypass pin. vref2 2 a in adc2 voltage reference input. 62 a in adc2,dac0,and dac1 voltage reference input. vrefd 3 a in dac0 and dac1 voltage reference input. ain0 18 12 a in adc0 signal input (see adc0 specification for complete descrip- tion). ain0g 19 13 a in adc0 dc bias input (see adc0 specification for complete description). ain1 9 5 a in adc1 signal input (see adc1 specification for complete descrip- tion). ain1g 8 4 a in adc1 dc bias input (see adc1 specification for complete description). cnvstr0 15 9 d in external conversion start source for adc0 cnvstr1 12 8 d in external conversion start source for adc1 cantx 94 59 d out controller area network transmit output. canrx 95 60 d in controller area network receive input. dac0 25 17 a out digital to analog converter 0 voltage output. (see dac specifica- tion for complete description). dac1 1 64 a out digital to analog converter 1 voltage output. (see dac specifica- tion for complete description). p0.0 62 51 d i/o port 0.0. see port input/output section for complete description. p0.1 61 50 d i/o port 0.1. see port input/output section for complete description. p0.2 60 49 d i/o port 0.2. see port input/output section for complete description. p0.3 59 48 d i/o port 0.3. see port input/output section for complete description. p0.4 58 47 d i/o port 0.4. see port input/output section for complete description. p0.5 57 46 d i/o port 0.5. see port input/output section for complete description. table 4.1. pin definitions name pin numbers type description f060 f061 f062 f063
page 38 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n p0.6 56 45 d i/o port 0.6. see port input/output section for complete description. p0.7 55 44 d i/o port 0.7. see port input/output section for complete description. p1.0/ain2.0 36 33 a in di/o adc2 input channel 0 (see adc2 specification for complete description). port 1.0. see port input/output section for complete description. p1.1/ain2.1 35 32 a in di/o adc2 input channel 1 (see adc2 specification for complete description). port 1.1. see port input/output section for complete description. p1.2/ain2.2 34 31 a in di/o adc2 input channel 2 (see adc2 specification for complete description). port 1.2. see port input/output section for complete description. p1.3/ain2.3 33 30 a in di/o adc2 input channel 3 (see adc2 specification for complete description). port 1.3. see port input/output section for complete description. p1.4/ain2.4 32 29 a in di/o adc2 input channel 4 (see adc2 specification for complete description). port 1.4. see port input/output section for complete description. p1.5/ain2.5 31 28 a in di/o adc2 input channel 5 (see adc2 specification for complete description). port 1.5. see port input/output section for complete description. p1.6/ain2.6 30 25 a in di/o adc2 input channel 6 (see adc2 specification for complete description). port 1.6. see port input/output section for complete description. p1.7/ain2.7 29 24 a in di/o adc2 input channel 7 (see adc2 specification for complete description). port 1.7. see port input/output section for complete description. p2.0 46 43 d i/o port 2.0. see port input/output section for complete description. p2.1 45 42 d i/o port 2.1. see port input/output section for complete description. p2.2 44 41 d i/o port 2.2. see port input/output section for complete description. p2.3 43 38 d i/o port 2.3. see port input/output section for complete description. p2.4 42 37 d i/o port 2.4. see port input/output section for complete description. p2.5 41 36 d i/o port 2.5. see port input/output section for complete description. p2.6 40 35 d i/o port 2.6. see port input/output section for complete description. p2.7 39 34 d i/o port 2.7. see port input/output section for complete description. table 4.1. pin definitions name pin numbers type description f060 f061 f062 f063
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 39 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information p3.0 54 d i/o port 3.0. see port input/output section for complete description. p3.1 53 d i/o port 3.1. see port input/output section for complete description. p3.2 52 d i/o port 3.2. see port input/output section for complete description. p3.3 51 d i/o port 3.3. see port input/output section for complete description. p3.4 50 d i/o port 3.4. see port input/output section for complete description. p3.5 49 d i/o port 3.5. see port input/output section for complete description. p3.6 48 d i/o port 3.6. see port input/output section for complete description. p3.7 47 d i/o port 3.7. see port input/output section for complete description. p4.5/ale 93 d i/o port 4.5. see port input/output section for complete description. ale strobe for external memory address bus (multiplexed mode). p4.6/rd 92 d i/o port 4.6. see port input/output section for complete description. /rd strobe for external memory address bus. p4.7/wr 91 d i/o port 4.7. see port input/output section for complete description. /wr strobe for external memory address bus. p5.0/a8 88 d i/o port 5.0. see port input/output section for complete description. bit 8 external memory address bus (non-multiplexed mode). p5.1/a9 87 d i/o port 5.1. see port input/output section for complete description. p5.2/a10 86 d i/o port 5.2. see port input/output section for complete description. p5.3/a11 85 d i/o port 5.3. see port input/output section for complete description. p5.4/a12 84 d i/o port 5.4. see port input/output section for complete description. p5.5/a13 83 d i/o port 5.5. see port input/output section for complete description. p5.6/a14 82 d i/o port 5.6. see port input/output section for complete description. p5.7/a15 81 d i/o port 5.7. see port input/output section for complete description. p6.0/a8m/a0 80 d i/o port 6.0. see port input/output section for complete description. bit 8 external memory address bus (multiplexed mode). bit 0 external memory address bus (non-multiplexed mode). p6.1/a9m/a1 79 d i/o port 6.1. see port input/output section for complete description. p6.2/a10m/a2 78 d i/o port 6.2. see port input/output section for complete description. p6.3/a11m/a3 77 d i/o port 6.3. see port input/output section for complete description. p6.4/a12m/a4 76 d i/o port 6.4. see port input/output section for complete description. table 4.1. pin definitions name pin numbers type description f060 f061 f062 f063
page 40 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n p6.5/a13m/a5 75 d i/o port 6.5. see port input/output section for complete description. p6.6/a14m/a6 74 d i/o port 6.6. see port input/output section for complete description. p6.7/a15m/a7 73 d i/o port 6.7. see port input/output section for complete description. p7.0/ad0m/d0 72 d i/o port 7.0. see port input/output section for complete description. bit 0 external memory address/data bus (multiplexed mode). bit 0 external memory data bus (non-multiplexed mode). p7.1/ad1m/d1 71 d i/o port 7.1. see port input/output section for complete description. p7.2/ad2m/d2 70 d i/o port 7.2. see port input/output section for complete description. p7.3/ad3m/d3 69 d i/o port 7.3. see port input/output section for complete description. p7.4/ad4m/d4 68 d i/o port 7.4. see port input/output section for complete description. p7.5/ad5m/d5 67 d i/o port 7.5. see port input/output section for complete description. p7.6/ad6m/d6 66 d i/o port 7.6. see port input/output section for complete description. p7.7/ad7m/d7 65 d i/o port 7.7. see port input/output section for complete description. table 4.1. pin definitions name pin numbers type description f060 f061 f062 f063
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 41 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information C8051F060/f062 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 42 43 44 45 46 47 48 49 50 1 2 3 4 5 6 7 8 9 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 75 74 73 72 71 70 69 68 67 p7.6/ad6m/d6 p7.7/ad7m/d7 vdd dgnd p0.0 p0.1 p0.2 p0.3 p0.4 p0.5 p0.6 p0.7 p3.3 p6.5/a13m/a5 p6.6/a14m/a6 p6.7/a15m/a7 p7.0/ad0m/d0 p7.1/ad1m/d1 p7.2/ad2m/d2 p7.3/ad3m/d3 p7.4/ad4m/d4 p7.5/ad5m/d5 /rst tdo tdi tck tms canrx cantx p4.5/ale p4.6/rd p4.7/wr vdd dgnd p5.0/a8 p5.1/a9 p5.2/a10 p5.3/a11 p5.4/a12 p5.5/a13 p5.6/a14 p5.7/a15 p6.0/a8m/a0 p6.1/a9m/a1 p6.2/a10m/a2 p6.3/a11m/a3 p6.4/a12m/a4 agnd av+ cnvstr1 avdd agnd cnvstr0 av+ agnd ain0 ain0g vrgnd0 vref0 vbgap0 agnd av+ dac0 dac1 vref2 vrefd vref vbgap1 vref1 vrgnd1 ain1g ain1 xtal1 xtal2 monen p1.7/ain2.7 p1.6/ain2.6 p1.5/ain2.5 p1.4/ain2.4 vdd dgnd p1.3/ain2.3 p1.2/ain2.2 p1.1/ain2.1 p1.0/ain2.0 p2.7 p2.6 p2.5 p2.4 p2.3 p2.2 p2.1 p2.0 p3.7 p3.6 p3.5 p3.4 p3.2 p3.1 p3.0 figure 4.1. tqfp-100 pinout diagram
page 42 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n a a1 a2 b d d1 e e e1 - 0.05 0.95 0.17 - - - - - - - 1.00 0.22 16.00 14.00 0.50 16.00 14.00 1.20 0.15 1.05 0.27 - - - - - min (mm) nom (mm) max (mm) 100 e a1 b a2 a pin 1 designator 1 e1 e d1 d figure 4.2. tqfp-100 package drawing
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 43 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information c8051f061/063 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 dac1 monen vref2 vref canrx cantx /rst tdo tdi vdd dgnd tck tms p0.0 p0.1 p0.2 p0.3 p0.4 p0.5 p0.6 p0.7 p2.0 p2.1 p2.2 vdd dgnd p2.3 p2.4 p2.5 p2.6 p2.7 p1.0/ain2.0 vbgap1 vref1 vrgnd1 ain1g ain1 agnd av+ cnvstr1 cnvstr0 av+ agnd ain0 ain0g vrgnd0 vref0 vbgap0 dac0 av+ agnd xtal1 xtal2 agnd avdd p1.7/ain2.7 p1.6/ain2.6 vdd dgnd p1.5/ain2.5 p1.4/ain2.4 p1.3/ain2.3 p1.2/ain2.2 p1.1/ain2.1 figure 4.3. tqfp-64 pinout diagram
page 44 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n a a1 a2 b d d1 e e e1 - 0.05 0.95 0.17 - - - - - - - - 0.22 12.00 10.00 0.50 12.00 10.00 1.20 0.15 1.05 0.27 - - - - - min (mm) nom (mm) max (mm) 1 64 e e1 e a1 b d d1 pin 1 designator a2 a figure 4.4. tqfp-64 package drawing
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 45 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 5. 16-bit adcs (adc0 and adc1) the adc subsystem for the C8051F060/1/2/3 consists of two 1 msps,16-bit successive-approximation-register adcs with integrated track-and-hold,a programmable window detector,and a dma interface (see block diagrams in figure 5.1 and figure 5.2). the adcs can be configured as two separate,single-ended adcs,or as a differential pair. the data conversion modes,window detector,and dma interface are all configurable under software control via the special function registers shown in figure 5.1 and figure 5.2. the voltage references used by adc0 and adc1 are selected as described in section 5.2 . the adcs and their respective track-and-hold circuitry can be inde- pendently enabled or disabled with the special function registers. either adc can be enabled by setting the adnen bit in the adcs control register (adcncn) to logic 1. the adcs are in low power shutdown when these bits are logic 0. ain0g ref 16 av+ ad0en sysclk ain0 start conversion timer 3 overflow timer 2 overflow 00 01 10 11 ad0busy (w) cnvstr0 16-bit sar adc0 adc0cf ad0ocal ad0lcal ad0gcal ad0scal ad0sc0 ad0sc1 ad0sc2 ad0sc3 adc0cn ad0wint ad0cm0 ad0cm1 ad0busy ad0int ad0tm ad0en ref 16 av+ ad1en sysclk ain1 start conversion timer 3 overflow timer 2 overflow ad1busy (w) cnvstr1 16-bit sar adc1 adc1cf ad1ocal ad1lcal ad1gcal ad1scal ad1sc0 ad1sc1 ad1sc2 ad1sc3 adc1cn ad1cm0 ad1cm1 ad1cm2 ad1busy ad1int ad1tm ad1en ad0busy (w) 000 010 100 110 xx1 adc0 data bus adc1 data bus ain1g (dc, -0.2 to 0.6 v) (dc, -0.2 to 0.6 v) figure 5.1. 16-bit adc0 and adc1 control path diagram
page 46 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 5.1. single-ended or differential operation adc0 and adc1 can be programmed to operate independently as single-ended adcs,or together to accept a differ- ential input. in single-ended mode,the adcs can be configured to sample simultaneously,or to use different conver- sion speeds. in differential mode,adc1 is a slave to adc0,and its configuration is based on adc0 settings,except during offset or gain calibrations. the diffsel bit in the channel select register amx0sl (figure 5.6) selects between single-ended and differential mode. 5.1.1. pseudo-differential inputs the inputs to the adcs are pseudo-differential. the actual voltage measured by each adc is equal to the voltage between the ainn pin and the ainng pin. ainng must be a dc signal between -0.2 and 0.6 v. in most systems, ainng will be connected to agnd. if not tied to agnd,the ainng signal can be used to negate a limited amount of fixed offset,but it is recommended that the internal offset calibration features of the device be used for this pur- pose. when operating in differential mode,ain0g and ain1g should be tied together. ainn must remain above ainng in both modes for accurate conversion results. 16 ain0 16-bit sar adc0 amx0sl diffsel 16 ain1 16-bit sar adc1 adc0h adc0l adc1h adc1l 8 8 0 1 8 8 single-ended differential adc0ltl adc0lth adc0gtl adc0gth 32 16 ad0wint window compare 16 dma interface + - ain0g ain1g figure 5.2. 16-bit adc0 and adc1 data path diagram
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 47 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 5.2. voltage reference the voltage reference circuitries for adc0 and adc1 allow for many different voltage reference configurations. each adc has the capability to use its own dedicated,on-chip voltage reference,or an off-chip reference circuit. a block diagram of the reference circuitry for one adc is shown in figure 5.3. the internal voltage reference circuit for each adc consists of an independent,temperature stable 1.25 v bandgap voltage reference generator,with an output buffer amplifier which multiplies the bandgap reference by 2. the maxi- mum load seen by the vrefn (vref0 or vref1) pin must be less than 100 a to agnd. bypass capacitors of 0.1 f and 47 f are recommended from the vrefn pin to vrgndn. the voltage reference circuitry for each adc is controlled in the reference control registers. ref0cn (defined in figure 5.11) is the reference control register for adc0,and ref1cn (defined in figure 5.12) is the reference control register for adc1. the refncn registers are used to enable/disable the internal reference and bias genera- tor circuitry for each adc independently. the biasen bits enable the on-board bias generators for each adc,while the refben bits enable the 2x buffer amplifiers which drive the vrefn pins. when disabled,the supply current drawn by the bandgap and buffer amplifier falls to less than 1 a (typical) and the output of the buffer amplifier enters a high impedance state (approximately 25 k ohms). if the internal voltage reference for an adc is used,the biasen and refben bits for that adc must both be set to logic 1. if an external reference is used,the refben bit should be set to logic 0. note that the biasen bit for an adc must be set to logic 1 to enable that adc,regardless of the voltage reference that is used. if an adc is not being used,the biasen bit can be set to logic 0 to conserve power. the electrical specifications for the voltage references are given in table 5.3. recommended bypass capacitors x2 adcn ref refncn refben biasen 1.25v band-gap en vbgapn 0.1 f bias vrefn 47 f0.1 f vrgndn external voltage reference figure 5.3. voltage reference block diagram
page 48 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 5.3. adc modes of operation adc0 and adc1 have a maximum conversion speed of 1 msps. the conversion clocks for the adcs are derived from the system clock. the adcnsc bits in the adcncf register determine how many system clocks (from 1 to 16) are used for each conversion clock. 5.3.1. starting a conversion for adc0,conversions can be initiated in one of four ways,depending on the programmed states of the adc0 start of conversion mode bits (ad0cm1,ad0cm0) in adc0cn. for adc0,conversions may be initiated by: 1. writing a 1 to the ad0busy bit of adc0cn; 2. a timer 3 overflow (i.e. timed continuous conversions); 3. a rising edge detected on the external adc convert start signal,cnvstr0; 4. a timer 2 overflow (i.e. timed continuous conversions). adc1 conversions can be initiated in five different ways,according to the adc1 start of conversion mode bits (ad1cm2-ad1cm0) in adc1cn. for adc1,conversions may be initiated by: 1. writing a 1 to the ad1busy bit of adc1cn; 2. a timer 3 overflow (i.e. timed continuous conversions); 3. a rising edge detected on the external adc convert start signal,cnvstr1; 4. a timer 2 overflow (i.e. timed continuous conversions); 5. writing a 1 to the ad0busy bit of adc0cn. the adnbusy bit is set to logic 1 during conversion and restored to logic 0 when conversion is complete. the fall- ing edge of adnbusy triggers an interrupt (when enabled) and sets the adnint interrupt flag (adcncn.5). in sin- gle-ended mode,the converted data for adcn is available in the adcn data word msb and lsb registers,adcnh, adcnl. in differential mode,the converted data (combined from adc0 and adc1) is available in the adc0 data word msb and lsb registers,adc0h,adc0l. when initiating conversions by writing a 1 to adnbusy,the adnint bit should be polled to determine when a conversion has completed (adcn interrupts may also be used). the recommended polling procedure is shown below. step 1. write a 0 to adnint; step 2. write a 1 to adnbusy; step 3. poll adnint for 1; step 4. process adcn data. when an external start-of-conversion source is required in differential mode the two pins (cnvstr0 and cnvstr1) should be tied together.
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 49 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 5.3.2. tracking modes the adntm bit in register adcncn controls the adcn track-and-hold mode. when the adc is enabled,the adc input is continuously tracked when a conversion is not in progress. when the adntm bit is logic 1,each conversion is preceded by a tracking period of 18 sar clocks (after the start-of-conversion signal). when the cnvstrn signal is used to initiate conversions,the adc will track until a rising edge occurs on the cnvstrn pin (see figure 5.4 and table 5.1 for conversion timing parameters). setting adntm to 1 can be useful to ensure that settling time require- ments are met when an external multiplexer is used on the analog input (see section 5.3.3. settling time require- ments on page 51 ). cnvstrn timer 2, timer 3 overflow; write '1' to adnbusy adcntm=1 adcntm=0 a. adc timing for external trigger source b. adc timing for internal trigger sources track convert track track track convert track track convert track t conv t conv t conv figure 5.4. adc track and conversion example timing
page 50 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n table 5.1. conversion timing (t conv ) adnsc3-0 adcntm = 0 adcntm = 1 adnsc3-0 adcntm = 0 adcntm = 1 0000 21*sysclk 38*sysclk 1000 171*sysclk 315*sysclk 0001 40*sysclk 72*sysclk 1001 189*sysclk 349*sysclk 0010 58*sysclk 106*sysclk 1010 208*sysclk 384*sysclk 0011 78*sysclk 142*sysclk 1011 226*sysclk 418*sysclk 0100 97*sysclk 177*sysclk 1100 245*sysclk 453*sysclk 0101 115*sysclk 211*sysclk 1101 263*sysclk 487*sysclk 0110 134*sysclk 246*sysclk 1110 282*sysclk 522*sysclk 0111 152*sysclk 280*sysclk 1111 300*sysclk 556*sysclk
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 51 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 5.3.3. settling time requirements if the input to the adc is changed rapidly (such as an external multiplexer change or any other form of step input),a minimum tracking time is required before an accurate conversion can be performed. this tracking time is determined by the adc input resistance,the adc sampling capacitance,any external source resistance,and the accuracy required for the conversion. figure 5.5 shows the equivalent adc input circuits for both differential and single- ended modes. notice that the equivalent time constant for both input circuits is the same. the required settling time for a given settling accuracy ( sa ) may be approximated by equation 5.1. an absolute minimum settling time of 280 ns is required after any step change on the input. where: sa is the settling accuracy,given as a fraction of an lsb (for example,0.25 to settle within 1/4 lsb) t is the required settling time in seconds r total is the sum of the adc input resistance and any external source resistance. n is the adc resolution in bits (16). equation 5.1. adc0 settling time requirements t 2 n sa ------ - ?? ?? r total c sample ln = r ain =30 ? rc input =r ain *c sample r ain =30 ? c sample =80pf c sample =80pf differential mode ain0 ain1 r ain =30 ? c sample =80pf rc input =r ain *c sample single-ended mode ain0 or ain1 figure 5.5. adc0 and adc1 equivalent input circuits
page 52 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 5.6. amx0sl: amux configuration register bit 7: reserved. write to 0b. bit 6: diffsel: fully differential conversion mode select bit. 0: operate in single-ended mode. 1: operate in differential mode. bit 5-0: reserved. write to 000000b. note: for single-ended mode,the adc0 data word is stored in adc0h and adc0l,while the adc1 data word is stored in adc1h and adc1l. in differential mode,the combined adc data word is stored in adc0h and adc0l,and is a 2s complement number. adc1s data word (single-ended) is also stored in adc1h and adc1l. sfr page: sfr address: 0 0xbb r/wr/wr/wr/wr/wr/wr/wr/wresetvalue - diffsel - - - - - - 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 53 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 5.7. adc0cf: adc0 configuration register bits 7-4: ad0sc3-0: adc0 sar conversion clock period bits. sar conversion clock is divided down from the system clock according to the ad0sc bits (ad0sc3-0). the number of system clocks used for each sar conversion clock is equal to ad0sc + 1. (note: the adc0 sar conversion clock should be less than or equal to 25 mhz). see table 5.1 for conversion timing details. bit 3: ad0scal: system calibration enable. 0: internal ground and reference voltage are used during offset and gain calibration. 1: external voltages can be used during offset and gain calibration. bit 2: ad0gcal: gain calibration. read: 0: gain calibration is completed or not yet started. 1: gain calibration is in progress. write: 0: no effect. 1: initiates a gain calibration if adc0 is idle. bit 1: ad0lcal: linearity calibration read 0: linearity calibration is completed or not yet started 1: linearity calibration is in progress write 0: no effect 1: initiates a linearity calibration if adc0 is idle bit0: ad0ocal:offsetcalibration. read: 0: offset calibration is completed or not yet started. 1: offset calibration is in progress. write: 0: no effect. 1: initiates an offset calibration if adc0 is idle. sfr page: sfr address: 0 0xbc r/wr/wr/wr/wr/wr/wr/wr/wresetvalue ad0sc3 ad0sc2 ad0sc1 ad0sc0 ad0scal ad0gcal ad0lcal ad0ocal 11110000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
page 54 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 5.8. adc1cf: adc1 configuration register bits 7-4: ad1sc3-0: adc1 sar conversion clock period bits. sar conversion clock is divided down from the system clock according to the ad1sc bits (ad1sc3-0). the number of system clocks used for each sar conversion clock is equal to ad1sc + 1. (note: the adc1 sar conversion clock should be less than or equal to 25 mhz). see table 5.1 for conversion timing details. bit 3: ad1scal: system calibration enable. 0: internal ground and reference voltage are used for offset and gain calibration. 1: external voltages can be used for offset and gain calibration. bit 2: ad1gcal: gain calibration. read: 0: gain calibration is completed or not yet started. 1: gain calibration is in progress. write: 0: no effect. 1: initiates a gain calibration if adc1 is idle. bit 1: ad1lcal: linearity calibration read 0: linearity calibration is completed or not yet started 1: linearity calibration is in progress write 0: no effect 1: initiates a linearity calibration if adc1 is idle bit0: ad1ocal:offsetcalibration. read: 0: offset calibration is completed or not yet started. 1: offset calibration is in progress. write: 0: no effect. 1: initiates an offset calibration if adc1 is idle. sfr page: sfr address: 1 0xbc r/wr/wr/wr/wr/wr/wr/wr/wresetvalue ad1sc3 ad1sc2 ad1sc1 ad1sc0 ad1scal ad1gcal ad1lcal ad1ocal 11110000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 55 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 5.9. adc0cn: adc0 control register bit 7: ad0en: adc0 enable bit. 0: adc0 disabled. adc0 is in low-power shutdown. 1: adc0 enabled. adc0 is active and ready for data conversions or calibrations. bit 6: ad0tm: adc track mode bit. 0: when the adc is enabled,tracking is continuous unless a conversion is in process. 1: tracking defined by ad0cm1-0 bits. bit 5: ad0int: adc0 conversion complete interrupt flag. this flag must be cleared by software. 0: adc0 has not completed a data conversion since the last time this flag was cleared. 1: adc0 has completed a data conversion. bit 4: ad0busy: adc0 busy bit. read: 0: adc0 conversion is complete or a conversion is not currently in progress. ad0int is set to logic 1 on the falling edge of ad0busy. 1: adc0 conversion is in progress. write: 0: no effect. 1: initiates adc0 conversion if ad0cm1-0 = 00b. bits 3-2: ad0cm1-0: adc0 start of conversion mode select. if ad0tm = 0: 00: adc0 conversion initiated on every write of 1 to ad0busy. 01: adc0 conversion initiated on overflow of timer 3. 10: adc0 conversion initiated on rising edge of external cnvstr0. 11: adc0 conversion initiated on overflow of timer 2. if ad0tm = 1: 00: tracking starts with the write of 1 to ad0busy and lasts for 16 sar clocks,followed by con- version. 01: tracking started by the overflow of timer 3 and lasts for 16 sar clocks,followed by conversion. 10: adc0 conversion starts on rising cnvstr0 edge. 11: tracking started by the overflow of timer 2 and lasts for 16 sar clocks,followed by conversion. bit 1: ad0wint: adc0 window compare interrupt flag. this bit must be cleared by software. 0: adc0 window comparison data match has not occurred since this flag was last cleared. 1: adc0 window comparison data match has occurred. bit 0: reserved: write to 0b. sfr page: sfr address: 0 0xe8 (bit addressable) r/w r/w r/w r/w r/w r/w r/w r/w reset value ad0en ad0tm ad0int ad0busy ad0cm1 ad0cm0 ad0wint - 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
page 56 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 5.10. adc1cn: adc1 control register bit 7: ad1en: adc1 enable bit. 0: adc1 disabled. adc1 is in low-power shutdown. 1: adc1 enabled. adc1 is active and ready for data conversions or calibrations. bit 6: ad1tm: adc track mode bit. 0: when the adc is enabled,tracking is continuous unless a conversion is in process. 1: tracking defined by ad1cm2-0 bits. bit 5: ad1int: adc1 conversion complete interrupt flag. this flag must be cleared by software. 0: adc1 has not completed a data conversion since the last time this flag was cleared. 1: adc1 has completed a data conversion. bit 4: ad1busy: adc1 busy bit. read: 0: adc1 conversion is complete or a conversion is not currently in progress. ad1int is set to logic 1 on the falling edge of ad1busy. 1: adc1 conversion is in progress. write: 0: no effect. 1: initiates adc1 conversion if ad1cm2-0 = 000b. bits 3-1: ad1cm2-0: adc1 start of conversion mode select. if ad1tm = 0: 000: adc1 conversion initiated on every write of 1 to ad1busy. 010: adc1 conversion initiated on overflow of timer 3. 100: adc1 conversion initiated on rising edge of external cnvstr1. 110: adc1 conversion initiated on overflow of timer 2. xx1: adc1 conversion initiated on every write of 1 to ad0busy in adc0cn if ad1tm = 1: 000: tracking starts with the write of 1 to ad1busy and lasts for 16 sar clocks,followed by con- version. 010: tracking started by the overflow of timer 3 and lasts for 16 sar clocks,followed by conver- sion. 100: adc1 conversion starts on rising cnvstr1 edge. 110: tracking started by the overflow of timer 2 and lasts for 16 sar clocks,followed by conver- sion. xx1: tracking starts with the write of 1 to ad0busy and lasts for 16 sar clocks,followed by con- version. bit 0: reserved: write to 0b. sfr page: sfr address: 1 0xe8 (bit addressable) r/w r/w r/w r/w r/w r/w r/w r/w reset value ad1en ad1tm ad1int ad1busy ad1cm2 ad1cm1 ad1cm0 - 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 57 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 5.11. ref0cn: reference control register 0 bits7-2: reserved. read = 000000b; write = 000000b. bit1: biase0: adc0 bias generator enable bit. (must be 1 if using adc0). 0: adc0 internal bias generator off. 1: adc0 internal bias generator on. bit0: refbe0: internal reference buffer for adc0 enable bit. 0: internal reference buffer for adc0 off. external voltage reference can be used. 1: internal reference buffer for adc0 on. internal voltage reference is driven on the vref0 pin. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue - - - - - - biase0 refbe0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd1 0 figure 5.12. ref1cn: reference control register 1 bits7-2: reserved. read = 000000b; write = 000000b. bit1: biase1: adc1 bias generator enable bit. (must be 1 if using adc1). 0: adc1 internal bias generator off. 1: adc1 internal bias generator on. bit0: refbe1: internal reference buffer for adc1 enable bit. 0: internal reference buffer for adc1 off. external voltage reference can be used. 1: internal reference buffer for adc1 on. internal voltage reference is driven on the vref1 pin. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue - - - - - - biase1 refbe1 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd1 1
page 58 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 5.13. adc0h: adc0 data word msb register bits 7-0: adc0 data word high-order bits. sfr page: sfr address: 0 0xbf r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 5.14. adc0l: adc0 data word lsb register bits 7-0: adc0 data word low-order bits. sfr page: sfr address: 0 0xbe r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 59 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 5.15. adc0 data word example 16-bit adc0 data word appears in the adc0 data word registers as follows: example: adc0 data word conversion map,ain0 input in single-ended mode (amx0sl = 0x00) example: adc0 data word conversion map,ain0-ain1 differential input pair (amx0sl = 0x40) ; n = 16 for single-ended; n=15 for differential. ain0-ain0g (volts) adc0h:adc0l vref * (65535/65536) 0xffff vref / 2 0x8000 vref * (32767/65536) 0x7fff 0 0x0000 ain0-ain1 (volts) adc0h:adc0l vref * (32767/32768) 0x7fff vref / 2 0x4000 vref * (1/32768) 0x0001 0 0x0000 -vref * (1/32768) 0xffff -vref / 2 0xc000 -vref 0x8000 code vin gain vref --------------- 2 n =
page 60 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 5.16. adc1h: adc1 data word msb register bits 7-0: adc1 data word high-order bits. sfr page: sfr address: 1 0xbf r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 5.17. adc1l: adc1 data word lsb register bits 7-0: adc1 data word low-order bits. sfr page: sfr address: 1 0xbe r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 5.18. adc1 data word example 16-bit adc1 data word appears in the adc1 data word registers as follows: example: adc1 data word conversion map,ain1 input in single-ended mode (amx1sl = 0x00) ;n=16 for differential mode,the differential data word appears in adc0h and adc0l. the single-ended adc1 results are always present in adc1h and adc1l,regardless of the operating mode. ain1-ain1g (volts) adc1h:adc1l vref * (65535/65536) 0xffff vref / 2 0x8000 vref * (32767/65536) 0x7fff 0 0x0000 code vin gain vref --------------- 2 n =
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 61 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 5.4. calibration the adcs are calibrated for linearity,offset,and gain in production. adc0 and adc1 can also be independently cal- ibrated for each of these parameters in-system. calibrations are initiated using bits in the adc0 or adc1 configura- tion register. the calibration coefficients can be accessed using the adc calibration pointer register (adc0cpt, figure 5.22) and the adc calibration coefficient register (adc0ccf,figure 5.23). the cptr bits in adc0cpt allow the adc0ccf register to read and write specific calibration coefficients. figure 5.19 shows the calibration coefficient locations. the adcs are calibrated for linearity in production. under normal circumstances,no additional linearity calibration is necessary. if linearity calibrations are desired,they can be initiated by setting the adcnlcal bit to 1. when the calibration is finished,the adcnlcal bit will be set to 0 by the hardware. linearity calibration coefficients are stored in the trim locations shown in equation 5.19. offset and gain calibrations can be performed using either internal or external voltages as calibration sources. the adcnscal bit determines whether the internal or external voltages are used in the calibration process. to ensure accuracy,offset calibration should be done prior to a gain calibration. the offset and gain calibration coefficients are decoded in figure 5.20. offset calibration is initiated by setting the adcnocal bit to 1. when the calibration is finished,the adcnocal bit will be set to 0 by the hardware. offset calibration can compensate for offset errors of approximately 3.125% of full scale. the offset value is added to the ainng input prior to digitization by the adc. gain calibration is initiated by setting the adcngcal bit to 1. when the calibration is finished,the adcngcal bit will be set to 0 by the hardware. gain calibration can compensate for slope errors of approximately 3.125%. the gain value is added to the adcs vref path to change the slope of the converters transfer function. figure 5.21 shows how the offset and gain values affect the analog signals used by the adc. figure 5.19. calibration coefficient locations adc0ccf adc0cpt bits 5-0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 0x00 linearity calibration coefficients (locations 0x00 through 0x12) . . 0x12 0x13 offset7 offset6 offset5 offset4 offset3 offset2 offset1 offset0 0x14 offset13 offset12 offset11 offset10 offset9 offset8 0x15 gain7 gain6 gain5 gain4 gain3 gain2 gain1 gain0 0x16 gain12 gain11 gain10 gain9 gain8
page 62 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n the offset register value affects the offset at the analog input as follows: the gain register value affects the slope of the adc transfer function as follows: offset register (14 bits) approximate offset change (v) 0x3fff -3.125% * vref 0x2000 0 0x0000 +3.125% * vref gain register (13 bits) approximate slope change 0x1fff +3.125% 0x1000 0 0x0000 -3.125% offset change 0x2000 offset register C 8192 ------------------------------------------------------------ 3 . 1 2 5 % vref ? slope change gain register 0x1000 C 4096 -------------------------------------------------------- -3.125% ? figure 5.20. offset and gain register mapping ainn adcn offset + vref gain adcn data 16 ainng - + figure 5.21. offset and gain calibration block diagram
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 63 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 5.22. adc0cpt: adc calibration pointer register bit 7: incr: pointer address automatic increment. 0: disable auto-increment. 1: enable auto-increment. cptr5-0 will automatically be incremented after each read or write to adc0ccf. bit 6: adcsel: adc calibration coefficient select. 0: reads and writes of adc0ccf will access adc0 calibration coefficients. 1: reads and writes of adc0ccf will access adc1 calibration coefficients. bits 5-0: cptr5-0: calibration coefficent pointer. select which calibration coefficient location will be accessed when adc0ccf is read or written. sfr page: sfr address: f 0xba r/wr/wr/wr/wr/wr/wr/wr/wresetvalue incr adcsel cptr5 cptr4 cptr3 cptr2 cptr1 cptr0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 5.23. adc0ccf: adc calibration coefficient register bits 7-0: calibration coefficients at the location specified in adc0cpt. see table 5.19. sfr page: sfr address: f 0xbb r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
page 64 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 5.5. adc0 programmable window detector the adc0 programmable window detector continuously compares the adc0 output to user-programmed limits, and notifies the system when an out-of-bound condition is detected. this is especially effective in an interrupt-driven system,saving code space and cpu bandwidth while delivering faster system response times. the window detector interrupt flag (ad0wint in adc0cn) can also be used in polled mode. the high and low bytes of the reference words are loaded into the adc0 greater-than and adc0 less-than registers (adc0gth,adc0gtl,adc0lth, and adc0ltl). the window detector can be used in single-ended or differential mode. in signle-ended mode,the window detector compares the adc0gtx and adc0ltx registers to the output of adc0. in differential mode,the combined output of adc0 and adc1 (contained in the adc0 data registers) is used for the comparison. reference comparisons are shown starting on page 66. notice that the window detector flag can be asserted when the measured data is inside or outside the user-programmed limits,depending on the programming of the adc0gtx and adc0ltx registers. figure 5.24. adc0gth: adc0 greater-than data high byte register bits 7-0: high byte of adc0 greater-than data word. sfr page: sfr address: 0 0xc5 r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 5.25. adc0gtl: adc0 greater-than data low byte register bits 7-0: low byte of adc0 greater-than data word. sfr page: sfr address: 0 0xc4 r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 65 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information bits 7-0: high byte of adc0 less-than data word. sfr page: sfr address: 0 0xc7 r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 5.26. adc0lth: adc0 less-than data high byte register figure 5.27. adc0ltl: adc0 less-than data low byte register bits 7-0: low byte of adc0 less-than data word. sfr page: sfr address: 0 0xc6 r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
page 66 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 5.28. 16-bit adc0 window interrupt example: single-ended data given: amx0sl = 0x00, adc0lth:adc0ltl = 0x2000, adc0gth:adc0gtl = 0x1000. an adc0 end of conversion will cause an adc0 window compare interrupt (ad0wint = 1) if the resulting adc0 data word is < 0x2000 and > 0x1000. given: amx0sl = 0x00, adc0lth:adc0ltl = 0x1000, adc0gth:adc0gtl = 0x2000. an adc0 end of conversion will cause an adc0 window compare interrupt (ad0wint = 1) if the resulting adc0 data word is > 0x2000 or < 0x1000. 0xffff 0x2001 0x2000 0x1fff 0x1001 0x1000 0x0fff 0x0000 ad0wint=1 ad0wint not affected ad0wint not affected adc0 data word 0xffff 0x2001 0x2000 0x1fff 0x1001 0x1000 0x0fff 0x0000 ad0wint=1 ad0wint not affected ad0wint=1 adc0lth:adc0ltl adc0gth:adc0gtl adc0 data word adc0gth:adc0gtl adc0lth:adc0ltl 0 input voltage (ain0 - ain0g) ref x(65535/65536) ref x(4096/65536) ref x(8192/65536) 0 input voltage (ain0 - ain0g) ref x(65535/65536) ref x(4096/65536) ref x(8192/65536)
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 67 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 0x7fff 0x1001 0x1000 0x0fff 0x0000 0xffff 0xfffe 0x8000 ad0wint=1 ad0wint not affected ad0wint not affected 0x7fff 0x1001 0x1000 0x0fff 0x0000 0xffff 0xfffe 0x8000 ad0wint=1 ad0wint not affected input voltage (ain0 - ain1) ad0wint=1 adc0lth:adc0ltl adc0gth:adc0gtl adc0 data word adc0 data word adc0lth:adc0ltl adc0gth:adc0gtl -ref input voltage (ain0 - ain1) ref x(32767/32768) ref x(4096/32768) ref x(-1/32768) -ref ref x(32767/32768) ref x(4096/32768) ref x(-1/32768) figure 5.29. 16-bit adc0 window interrupt example: differential data given: amx0sl = 0x40, adc0lth:adc0ltl = 0x1000, adc0gth:adc0gtl = 0xffff. an adc0 end of conversion will cause an adc0 window compare interrupt (ad0wint = 1) if the resulting adc0 data word is < 0x1000 and > 0xffff. (in twos-complement math, 0xffff = -1.) given: amx0sl = 0x40, adc0lth:adc0ltl = 0xffff, adc0gth:adc0gtl = 0x1000. an adc0 end of conversion will cause an adc0 window compare interrupt (ad0wint = 1) if the resulting adc0 data word is < 0xffff or > 0x1000. (in twos-complement math, 0xffff = -1.)
page 68 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n table 5.2. 16-bit adc0 and adc1 electrical characteristics vdd = 3.0v,av+ = 3.0v,avdd = 3.0v,vref = 2.50v (refbe=0),-40c to +85c unless otherwise specified parameter conditions min typ max units dc accuracy resolution 16 bits integral nonlinearity (C8051F060/1) single-ended differential 0.75 0.5 2 1 lsb integral nonlinearity (c8051f062/3) single-ended differential 1.5 1 4 2 lsb differential nonlinearity guaranteed monotonic 0.5 lsb offset error 0.1 mv full scale error 0.008 %f.s. gain temperature coefficient tbd ppm/c dynamic performance signal-to-noise plus distortion fin = 10 khz,single-ended fin = 100 khz,single-ended fin = 10 khz,differential fin = 100 khz,differential 86 tbd 89 tbd db db db db total harmonic distortion fin = 10 khz,single-ended fin = 100 khz,single-ended fin = 10 khz,differential fin = 100 khz,differential 96 tbd 103 tbd db db db db spurious-free dynamic range fin = 10 khz,single-ended fin = 100 khz,single-ended fin = 10 khz,differential fin = 100 khz,differential 97 tbd 104 tbd db db db db cmrr fin = 10 khz 86 db channel isolation 100 db timing sar clock frequency 25 mhz conversion time in sar clocks 18 clocks track/hold acquisition time 280 ns throughput rate 1 msps aperture delay external cnvst signal 1.5 ns rms aperture jitter external cnvst signal 5 ps analog inputs input voltage range single-ended (ainn - ainng) differential (ain0 - ain1) 0 -vref vref vref v v input capacitance 80 pf
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 69 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information operating input range ain0 or ain1 ain0g or ain1g (dc only) -0.2 -0.2 av + 0.6 v v power specifications power supply current (each adc) operating mode,1 msps av + avdd shutdown mode 4.0 1.5 1 ma ma a power supply rejection vdd 5% 0.5 lsb table 5.3. voltage reference 0 and 1 electrical characteristics vdd = 3.0 v,av+ = 3.0 v,avdd = 3.0v,-40c to +85c unless otherwise specified parameter conditions min typ max units internal reference output voltage 25c ambient 2.45 v vref temperature coefficient 15 ppm/c power supply current (each volt- age reference) av + 1 . 5 m a external reference input voltage range 2.0 (av+ + 0.3) v input current adc throughput = 1 msps 450 a table 5.2. 16-bit adc0 and adc1 electrical characteristics vdd = 3.0v,av+ = 3.0v,avdd = 3.0v,vref = 2.50v (refbe=0),-40c to +85c unless otherwise specified parameter conditions min typ max units
page 70 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n notes
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 71 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 6. direct memory access interface (dma0) the dma interface works in conjunction with adc0 and adc1 to write adc outputs directly to a specified region of xram. the dma interface is configured by software using the special function registers shown in figure 6.1. up to 64 instructions can be programmed into the instruction buffer to designate a sequence of dma operations. the instruction buffer is accessed by the dma control logic,which gathers the appropriate data from the adcs and controls writes to xram. the dma instructions tell the dma control logic which adc(s) to expect results from, but do not initiate the actual conversions. it is important to configure the adcs for the desired start-of-conversion source,voltage reference,and sar clock frequency prior to starting the dma interface. for information on setting up the adcs,refer to section 5. 16-bit adcs (adc0 and adc1) on page 45 . 6.1. writing to the instruction buffer the instruction buffer has 64 8-bit locations that can be programmed with a sequence of dma instructions. filling the instruction buffer is done with the special function registers dma0ipt (dma instruction write address regis- ter,figure 6.6) and dma0idt (dma instruction write data register,figure 6.7). instructions are written to the instruction buffer at address dma0ipt when the instruction word is written to dma0idt. reading the register dma0idt will return the instruction word at location dma0ipt. after a write or read operation on dma0idt,the dma0ipt register is automatically incremented to the next instruction buffer location. ain0 adc0 ain1 adc1 dma control logic dma0idt instruction data dma0ipt address write logic dma0bnd start address instruction buffer (64 bytes) adc0en adc1en diffsel ccnv dma0isw current address xram (on-chip or off-chip) dma0dsh current xram address dma0dsl dma0dah beginning xram address dma0dal dma0csh current repeat counter value dma0csl dma0cth repeat counter limit dma0ctl address bus data bus dma0cf dma0eo dma0eoe dma0ci dma0cie dma0xby dma0hlt dma0cn dma0do0 dma0do1 dma0doe dma0de0 dma0de1 dma0md dma0int dma0en ain0g ain1g figure 6.1. dma0 block diagram
page 72 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 6.2. dma0 instruction format dma instructions can request single-ended data from both adc0 and adc1,as well as the differential combination of the two adc inputs. the instruction format is identical to the dma0idt register,shown in figure 6.7. depending on which bits are set to 1 in the instruction word,either 2 or 4 bytes of data will be written to xram for each dma instruction cycle (excluding end-of-operation instructions). table 6.1 details all of the valid dma instructions. instructions not listed in the table are not valid dma instructions,and should not be used. note that the adcs can be independently controlled by the microcontroller when their outputs are not requested by the dma. 6.3. xram addressing and setup the dma interface can be configured to access either on-chip or off-chip xram. any writes to on-chip xram by the dma control logic occur when the processor core is not accessing the on-chip xram. this ensures that the dma will not interfere with processor instruction timing. off-chip xram access (only available on the C8051F060/2) is controlled by the dma0hlt bit in dma0cf (dma configuration register,figure 6.5). the dma will have full access to off-chip xram when this bit is 0,and the processor core will have full access to off-chip xram when this bit is 1. the dma0hlt bit should be controlled in software when both the processor core and the dma interface require access to off-chip xram data space. before setting dma0hlt to 1,the software should check the dma0xby bit to ensure that the dma is not currently accessing off-chip xram. the processor core cannot access off-chip xram while dma0hlt is 0. the processor will continue as though it was able to perform the desired memory access,but the data will not be written to or read from off-chip xram. when the processor core is finished accessing off-chip xram,dma0hlt should be set back to 0in software to return control to the dma interface. the dma control logic will wait until dma0hlt is 0 before writing data to off-chip xram. if new data becomes available to the dma interface before the previous data has been written,an overflow condition will occur,and the new data word may be lost. the data address pointer registers (dma0dsh and dma0dsl) contain the 16-bit xram address location where the dma interface will write data. when the dma is initially enabled,the dma data address pointer registers are initialized to the values contained in the dma data address beginning registers (dma0dah and dma0dal). the data address pointer registers are automatically incremented by 2 or 4 after each data write by the dma inter- face. table 6.1. dma0 instruction set instruction word description first data written to xram (2 bytes) second data written to xram (2 bytes) 00000000b end-of-operation none none 10000000b end-of-operation with continuous conversion none none x0010000b retrieve adc0 data adc0h:adc0l none x0100000b retrieve adc1 data adc1h:adc1l none x0110000b retrieve adc0 and adc1 data adc0h:adc0l adc1h:adc1l x10x0000b retrieve differential data adc0h:adc0l (differential result from both adcs) none x11x0000b retrieve differential and adc1 data adc0h:adc0l (differential result from both adcs) adc1h:adc1l
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 73 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 6.4. instruction execution in mode 0 when the dma interface begins an operation cycle,the dma instruction status register (dma0isw,figure 6.9) is loaded with the address contained in the dma instruction boundary register (dma0bnd,figure 6.8). the instruc- tion is fetched from the instruction buffer,and the dma control logic waits for data from the appropriate adc(s). the dma will execute each instruction once,and then increment dma0isw to the next instruction address. when the current dma instruction is an end of operation instruction,the instruction status register is reset to the instruc- tion boundary register. if the continuous conversion bit (bit 7,ccnv) in the end of operation instruction word is set to 1,the repeat counter is ignored,and the dma will continue to execute instructions indefinitely. when ccnv is set to 0,the repeat counter (registers dma0csh and dma0csl) is decremented,and the dma will continue to execute instructions until the repeat counter reaches 0x0000. the repeat counter is initialized with the repeat counter limit value (registers dma0cth and dma0ctl) at the beginning of the dma operation. an example of mode 0 operation is shown in figure 6.2. 00000000 0x3f 00110000 00010000 01000000 0x01 0x02 0x03 ... 0x00 adc0h adc0l dma0bnd adc0h adc0l dma0csh:l = dma0cth:l dma0csh:l = dma0cth:l - 1 dma0csh:l = 0x0000 instruction buffer (64 bytes) xram adc0h (diff.) adc0l adc0h (diff.) adc0l (diff.) adc0h adc0l adc1h adc1l adc1h adc1l figure 6.2. dma mode 0 operation
page 74 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 6.5. instruction execution in mode 1 when the dma interface begins an operation cycle,the dma instruction status register (dma0isw,figure 6.9) is loaded with the address contained within the dma instruction boundary register (dma0bnd,figure 6.8). the instruction is fetched from the instruction buffer,and the dma control logic waits for data from the appropriate adc(s). at the end of an instruction,the repeat counter (registers dma0csh and dma0csl) is decremented, and the instruction will be repeated until the repeat counter reaches 0x0000. the repeat counter is then reset to the repeat counter limit value (registers dma0cth and dma0ctl),and the dma will increment dma0isw to the next instruction address. when the current dma instruction is an end of operation instruction,the instruction status register is reset to the instruction boundary register. if the continuous conversion bit (bit 7,ccnv) in the end of operation instruction word is set to 1,the dma will continue to execute instructions. when ccnv is set to 0,the dma will stop executing instructions at this point. an example of mode 1 operation is shown in figure 6.3. 00000000 0x3f 00110000 00010000 01000000 0x01 0x02 0x03 ... 0x00 dma0bnd adc0h adc0l instruction buffer (64 bytes) xram adc0h (diff.) adc0l (diff.) adc0h adc0l adc1h adc1l adc0h adc0l adc0h adc0l dma0csh:l = dma0cth:l dma0csh:l = dma0cth:l - 1 dma0csh:l = 0x0000 dma0csh:l = dma0cth:l adc0h (diff.) adc0l (diff.) dma0csh:l = 0x0000 dma0csh:l = dma0cth:l adc0h adc0l adc1h adc1l dma0csh:l = 0x0000 figure 6.3. dma mode 1 operation
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 75 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 6.6. interrupt sources the dma contains multiple interrupt sources. some of these can be individually enabled to generate interrupts as necessary. the dma control register (dma0cn,figure 6.4) and dma configuration register (dma0cf, figure 6.5) contain the enable bits and flags for the dma interrupt sources. when an interrupt is enabled and the interrupt condition occurs,a dma interrupt will be generated (eie2.7 is set to 1). the dma flags that can generate a dma0 interrupt are: 1. dma operations complete (dma0cn.6,dma0int) occurs when all dma operations have been completed,and the dma interface is idle. 2. adc1 data overflow error (dma0cn.4,dma0de1) occurs when the dma interface cannot access xram for two conversion cycles of adc1. this flag indicates that at least one conversion result from adc1 has been discarded. 3. adc0 data overflow error (dma0cn.3,dma0de0) occurs when the dma interface cannot access xram for two conversion cycles of adc0. this flag indicates that at least one conversion result from adc0 has been discarded. 4. adc1 data overflow warning (dma0cn.1,dma0do1) occurs when data from adc0 becomes available and the dma has not yet written the previous results to xram. this interrupt source can be enabled and disabled with the data overflow warning enable bit (dma0cn.2,dma0doe). 5. adc0 data overflow warning (dma0cn.0,dma0do0) occurs when data from adc1 becomes available and the dma has not yet written the previous results to xram. this interrupt source can be enabled and disabled with the data overflow warning enable bit (dma0cn.2,dma0doe). 6. repeat counter overflow (dma0cf.2,dma0ci) occurs when the repeat counter reaches the repeat counter limit. this interrupt source can be enabled and disabled with the repeat counter overflow inter- rupt enable bit (dma0cf.3,dma0cie). 7. end of operation (dma0cf.0,dma0eo) occurs when an end of operation instruction is reached in the instruction buffer. this interrupt source can be enabled and disabled with the end of operation interrupt enable bit (dma0cf.1,dma0eoe). 6.7. data buffer overflow warnings and errors the data paths from the adcs to xram are double-buffered when using the dma interface. when a conversion is completed by the adc,it first enters the adcs data register. if the dmas data buffer is empty,the conversion results will immediately be written into the dmas internal data buffer for that adc. data in the dmas internal data buffer is written to xram at the first available opportunity (see section 6.3. xram addressing and setup on page 72 ). conversion results from the adcs data registers are not copied into the dmas data buffer until data in the buffer has been written to xram. when a conversion is completed and the dmas data buffer is not empty,an over- flow warning flag is generated. if a second conversion data word becomes available before the dmas data buffer is written to xram,the data in the adcs data registers is over-written with the new data word,and a data overflow error flag is generated.
page 76 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 6.4. dma0cn: dma0 control register bit 7: dma0en: dma0 enable. write: 0: stop dma0 operations. 1:begindma0operations. read: 0: dma0 is idle. 1: dma0 operation is in progress. bit 6: dma0int: dma0 operations complete flag. 0: dma0 has not completed all operations. 1: dma0 operations are complete. this bit must be cleared by software. bit 5: dma0md: dma0 mode select. 0: dma0 will operate in mode 0. 1: dma0 will operate in mode 1. bit 4: dma0de1: adc1 data overflow error flag. 0: adc1 data overflow has not occured. 1: adc1 data overflow has occured,and data from adc1 has been lost. this bit must be cleared by software. bit 3: dma0de0: adc0 data overflow error flag. 0: adc0 data overflow has not occured. 1: adc0 data overflow has occured,and data from adc0 has been lost. this bit must be cleared by software. bit 2: dma0doe: data overflow warning interrupt enable. 0: disable data overflow warning interrupts. 1: enable data overflow warning interrups. bit 1: dma0do1: adc1 data overflow warning flag. 0: no adc1 data buffer warnings have been issued. 1: adc1 data buffer is full,and the dma has not written previous data to xram. this bit must be cleared by software. bit 0: dma0do0: adc0 data overflow warning flag. 0: no adc0 data buffer warnings have been issued. 1: adc0 data buffer is full,and the dma has not written previous data to xram. this bit must be cleared by software. sfr page: sfr address: 0x03 0xd8 (bit addressable) r/w r/w r/w r/w r/w r/w r/w r/w reset value dma0en dma0int dma0md dma0de1 dma0de0 dma0doe dma0do1 dma0do0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 77 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 6.5. dma0cf: dma0 configuration register bit 7: dma0hlt: halt dma0 off-chip xram access (C8051F060/2 only). 0: dma0 has complete access to off-chip xram. 1: processor core has complete access to off-chip xram. dma0 will wait until this bit is 0 before writing to off-chip xram locations. bit 6: dma0xby: off-chip xram busy flag (C8051F060/2 only). 0: dma0 is not accessing off-chip xram. 1: dma0 is accessing off-chip xram. bits 5-4: reserved. write to 00b. bit 3: dma0cie: repeat counter overflow interrupt enable. 0: disable repeat counter overflow interrupt. 1: enable repeat counter overflow interrupt. bit 2: dma0ci: repeat counter overflow flag. 0: repeat counter overflow has not occured. 1: repeat counter overflow has occured. this bit must be cleared by software. bit 1: dma0eoe: end-of-operation interrupt enable. 0: disable end-of-operation interrupt. 1: enable end-of-operation interrupt. bit 0: dma0eo: end-of-operation flag. 0: end-of-operation instruction has not been received. 1: end-of-operation instruction has been received. this bit must be cleared by software. sfr page: sfr address: 0x03 0xf8 (bit addressable) r/w r r/w r/w r/w r/w r/w r/w reset value dma0hlt dma0xby - - dma0cie dma0ci dma0eoe dma0eo 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
page 78 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 6.6. dma0ipt: dma0 instruction write address register bits 7-6: unused. bits 5-0: dma0 instruction address to write (or read). when dma0idt is written or read,this register will be incremented to point to the next instruction address. sfr page: sfr address: 0x03 0xdd r r r/wr/wr/wr/wr/wr/wresetvalue -- 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 6.7. dma0idt: dma0 instruction write data register bit 7: ccnv: continuous conversion. 0: disable continuous conversion. 1: enable continuous conversion. repeat counter value is ignored,and conversions will continue. bit6: diffsel:waitfordataindifferentialmode. 0: differential data will not be collected. 1: wait for differential data,and store to xram. bit 5: adc1en: wait for data from adc1. 0: adc1 data will not be collected. 1: wait for adc1 data,and store to xram. bit 4: adc0en: wait for data from adc0. 0: adc0 data will not be collected. 1: wait for adc0 data,and store to xram. if diffsel is also 1,only the differential data will be stored. bits 3-0: reserved. write to 0000b. for more details on dma instruction words,see section 6.2. dma0 instruction format on page 72 . ? this register points to a dedicated ram location and its reset value is indeterminate. sfr page: sfr address: 0x03 0xde r/wr/wr/wr/wr/wr/wr/wr/wresetvalue? ccnv diffsel adc1en adc0en - - - - xxxxxxxx bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 79 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 6.8. dma0bnd: dma0 instruction boundary register bits 7-6: unused. bits 5-0: dma0 instruction address to begin with when executing dma instructions. sfr page: sfr address: 3 0xfd r/wr/wr/wr/wr/wr/wr/wr/wresetvalue -- 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 6.9. dma0isw: dma0 instruction status register bits 7-6: unused. bits 5-0: contains the address of the current dma0 instruction to be executed. sfr page: sfr address: 3 0xfe r/wr/wr/wr/wr/wr/wr/wr/wresetvalue -- 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
page 80 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 6.10. dma0dah: dma0 data address beginning msb register bits 7-0: dma0 address beginning high-order bits. sfr page: sfr address: 3 0xda r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 6.11. dma0dal: dma0 data address beginning lsb register bits 7-0: dma0 address beginning low-order bits. sfr page: sfr address: 3 0xd9 r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 6.12. dma0dsh: dma0 data address pointer msb register bits 7-0: dma0 address pointer high-order bits. sfr page: sfr address: 3 0xdc r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 6.13. dma0dsl: dma0 data address pointer lsb register bits 7-0: dma0 address pointer low-order bits. sfr page: sfr address: 3 0xdb r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 81 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 6.14. dma0cth: dma0 repeat counter limit msb register bits 7-0: dma0 repeat counter limit high-order bits. sfr page: sfr address: 3 0xfa r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 6.15. dma0ctl: dma0 repeat counter limit lsb register bits 7-0: dma0 repeat counter limit low-order bits. sfr page: sfr address: 3 0xf9 r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 6.16. dma0csh: dma0 repeat counter msb register bits 7-0: dma0 repeat counter high-order bits. sfr page: sfr address: 3 0xfc r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 6.17. dma0csl: dma0 repeat counter lsb register bits 7-0: dma0 repeat counter low-order bits. sfr page: sfr address: 3 0xfb r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
page 82 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n notes
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 83 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 7. 10-bit adc (adc2) the adc2 subsystem for the C8051F060/1/2/3 consists of an analog multiplexer (referred to as amux2),and a 200 ksps,10-bit successive-approximation-register adc with integrated track-and-hold and programmable window detector (see block diagram in figure 7.1). the amux2,data conversion modes,and window detector can all be configured from within software via the special function registers shown in figure 7.1. adc2 operates in both sin- gle-ended and differential modes,and may be configured to measure any of the pins on port 1,or the temperature sensor output. the adc2 subsystem is enabled only when the ad2en bit in the adc2 control register (adc2cn) is set to logic 1. the adc2 subsystem is in low power shutdown when this bit is logic 0. 10-bit sar adc ref temp sensor 10 9-to-1 amux (se or diff) av+ 20 10 ad2en sysclk ain2.0 ain2.1 ain2.2 ain2.3 ain2.4 ain2.5 ain2.6 ain2.7 start conversion agnd adc2l adc2h adc2ltl adc2lth adc2gtl adc2gth ad2cm timer 3 overflow timer 2 overflow 00 01 10 11 ad2busy (w) cnvstr2 ad2wint comb. logic amx2sl amx2ad0 amx2ad1 amx2ad2 amx2ad3 amx2cf ain01ic ain23ic ain45ic ain67ic adc2cf ad2sc0 ad2sc1 ad2sc2 ad2sc3 ad2sc4 adc2cn ad2ljst ad2wint ad2cm0 ad2cm1 ad2busy ad2int ad2tm ad2en ad2cm figure 7.1. adc2 functional block diagram
page 84 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 7.1. analog multiplexer the analog multiplexer (amux2) selects the inputs to the adc,allowing any of the pins on port 1 to be measured in single-ended mode,or as a differential pair. additionally,the on-chip temperature sensor may be selected as a single- ended input. the adc2 input channels are configured and selected in the amx2cf and amx2sl registers as described in figure 7.5 and figure 7.6,respectively. in single-ended mode,the selected pin is measured with respect to agnd. in differential mode,the selected differential pair is measured with respect to one another. the polarity of the differential measurement depends on the setting of the amx2ad3-0 bits in the amx2sl register. for example, if pins ain2.0 and ain2.1 are configured for differential measurement (ain01ic = 1),and amx2ad3-0 = 0000b, the adc will measure the voltage (ain2.0 - ain2.1). if amx2ad3-0 is changed to 0001b,the adc will measure the same voltage,with opposite polarity (ain2.1 - ain2.0). the conversion code format differs between single-ended and differential modes. the registers adc2h and adc2l contain the high and low bytes of the output conversion code from the adc at the completion of each conversion. data can be right-justified or left-justified,depending on the setting of the ad2ljst bit (adc2cn.0). when in sin- gle-ended mode,conversion codes are represented as 10-bit unsigned integers. inputs are measured from 0 to vref * 1023/1024. example codes are shown below for both right-justified and left-justified data. unused bits in the adc2h and adc2l registers are set to 0. when in differential mode,conversion codes are represented as 10-bit signed 2s complement numbers. inputs are measured from -vref to vref * 511/512. example codes are shown below for both right-justified and left-justified data. for right-justified data,the unused msbs of adc2h are a sign-extension of the data word. for left-justified data,the unused lsbs in the adc2l register are set to 0. important note about adc2 input configuration: port 1 pins selected as adc2 inputs should be configured as analog inputs. to configure a port 1 pin for analog input,set to 1 the corresponding bit in register p1mdin. port 1 pins used as adc2 inputs will be skipped by the crossbar for peripheral assignments. see section 17. port input/output on page 191 for more port i/o configuration details. the temperature sensor transfer function is shown in figure 7.2 on page 85. the output voltage (v temp )isasingle- ended input to adc2 when the temperature sensor is selected by bits amx2ad3-0 in register amx2sl. input voltage right-justified adc2h:adc2l (ad2ljst = 0) left-justified adc2h:adc2l (ad2ljst = 1) vref * 1023/1024 0x03ff 0xffc0 vref * 512/1024 0x0200 0x8000 vref * 256/1024 0x0100 0x4000 0 0x0000 0x0000 input voltage right-justified adc2h:adc2l (ad2ljst = 0) left-justified adc2h:adc2l (ad2ljst = 1) vref * 511/512 0x01ff 0x7fc0 vref * 256/512 0x0100 0x4000 0 0x0000 0x0000 -vref * 256/512 0xff00 0xc000 - vref 0xfe00 0x8000
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 85 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 7.2. modes of operation adc2 has a maximum conversion speed of 200 ksps. the adc2 conversion clock is a divided version of the system clock,determined by the ad2sc bits in the adc2cf register (system clock divided by (ad2sc + 1) for 0 ad2sc 31). the adc2 conversion clock should be no more than 3 mhz. 7.2.1. starting a conversion a conversion can be initiated in one of four ways,depending on the programmed states of the adc2 start of conver- sion mode bits (ad2cm1-0) in register adc2cn. conversions may be initiated by one of the following: 1. writing a 1 to the ad2busy bit of register adc2cn 2. a timer 3 overflow (i.e. timed continuous conversions) 3. a rising edge on the cnvstr2 input signal (assigned by the crossbar) 4. a timer 2 overflow when cnvstr2 is used as a conversion start source,it must be enabled in the crossbar,and the corresponding pin must be set to open-drain,high-impedance mode (see section 17. port input/output on page 191 for more details on port i/o configuration). writing a 1 to ad2busy provides software control of adc2 whereby conversions are performed "on-demand". during conversion,the ad2busy bit is set to logic 1 and reset to logic 0 when the conversion is complete. the fall- ing edge of ad2busy triggers an interrupt (when enabled) and sets the adc2 interrupt flag (ad2int). note: when polling for adc conversion completions,the adc2 interrupt flag (ad2int) should be used. converted data is avail- able in the adc2 data registers,adc2h and adc2l,when bit ad2int is logic 1. note that when timer 2 or timer 3 overflows are used as the conversion source,low byte overflows are used if the timer is in 8-bit mode; and high byte overflows are used if the timer is in 16-bit mode. see section 23. timers on page 271 for timer con- figuration. figure 7.2. typical temperature sensor transfer function 0 -50 50 100 (celsius) 0.700 0.800 0.900 1.000 1.100 (volts) v temp = 0.0033*(temp c )+0.89 1.200
page 86 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 7.2.2. tracking modes the ad2tm bit in register adc2cn controls the adc2 track-and-hold mode. in its default state,the adc2 input is continuously tracked,except when a conversion is in progress. when the ad2tm bit is logic 1,adc2 operates in low-power track-and-hold mode. in this mode,each conversion is preceded by a tracking period of 3 sar clocks (after the start-of-conversion signal). when the cnvstr2 signal is used to initiate conversions in low-power track- ing mode,adc2 tracks only when cnvstr2 is low; conversion begins on the rising edge of cnvstr2 (see figure 7.3). tracking can also be disabled (shutdown) when the device is in low power standby or sleep modes. low- power track-and-hold mode is also useful when amux settings are frequently changed,due to the settling time requirements described in section 7.2.3. settling time requirements on page 87 . figure 7.3. 10-bit adc track and conversion example timing write '1' to ad2busy, timer 3, timer 2 overflow (ad2cm[1:0]=00, 01, 11) ad2tm=1 track convert low power mode ad2tm=0 track or convert convert track low power or convert sar clocks 123456789101112 123456789 sar clocks b. adc2 timing for internal trigger source 123456789 cnvstr2 (ad2cm[1:0]=10) ad2tm=1 a. adc2 timing for external trigger source sar clocks trackorconvert convert track ad2tm=0 track convert low power mode low power or convert 10 11 13 14 10 11
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 87 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 7.2.3. settling time requirements when the adc2 input configuration is changed (i.e.,a different amux2 selection is made,or an external multi- plexer is switched),a minimum tracking time is required before an accurate conversion can be performed. this track- ing time is determined by the amux2 resistance,the adc2 sampling capacitance,any external source resistance, and the accuracy required for the conversion. note that in low-power tracking mode,three sar clocks are used for tracking at the start of every conversion. for most applications,these three sar clocks will meet the minimum track- ing time requirements. figure 7.4 shows the equivalent adc2 input circuits for both differential and single-ended modes. notice that the equivalent time constant for both input circuits is the same. the required adc2 settling time for a given settling accuracy (sa) may be approximated by equation 7.1. when measuring the temperature sensor output, r total reduces to r mux . see table 7.1 for adc2 minimum settling time requirements. where: sa is the settling accuracy,given as a fraction of an lsb (for example,0.25 to settle within 1/4 lsb) t is the required settling time in seconds r total is the sum of the amux2 resistance and any external source resistance. n is the adc resolution in bits (10). equation 7.1. adc2 settling time requirements t 2 n sa ------ - ?? ?? r total c sample ln = r mux =5k rc input =r mux *c sample r mux =5k c sample = 5pf c sample = 5pf mux select mux select differential mode p1.x p1.y r mux =5k c sample = 5pf rc input =r mux *c sample mux select single-ended mode p1.x figure 7.4. adc2 equivalent input circuits
page 88 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 7.5. amx2cf: amux2 configuration register bits 7-4: unused. read = 0000b; write = dont care. bit 3: ain67ic: ain2.6,ain2.7 input pair configuration bit. 0: ain2.6 and ain2.7 are independent,single-ended inputs. 1: ain2.6 and ain2.7 are a differential input pair. bit 2: ain45ic: ain2.4,ain2.5 input pair configuration bit. 0: ain2.4 and ain2.5 are independent,single-ended inputs. 1: ain2.4 and ain2.5 are a differential input pair. bit 1: ain23ic: ain2.2,ain2.3 input pair configuration bit. 0: ain2.2 and ain2.3 are independent,single-ended inputs. 1: ain2.2 and ain2.3 are a differential input pair. bit 0: ain01ic: ain2.0,ain2.1 input pair configuration bit. 0: ain2.0 and ain2.1 are independent,single-ended inputs. 1: ain2.0 and ain2.1 are a differential input pair. note: the adc2 data word is in the 2s complement format for channels configured as differential. the polarity of a differential measurement is determined by the amx2sl setting. see figure 7.5 for more details on multiplexer channel selection. sfr page: sfr address: 2 0xba r/wr/wr/wr/wr/wr/wr/wr/wresetvalue - - - - ain67ic ain45ic ain23ic ain01ic 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 89 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 7.6. amx2sl: amux2 channel select register bits 7-4: unused. read = 0000b; write = dont care. bits 3-0: amx2ad3-0: amx2 address bits. 0000-1111b: adc input multiplexer channel selected per chart below. sfr page: sfr address: 2 0xbb r/w r/w r/w r/w r/w r/w r/w r/w reset value - - - - amx2ad3 amx2ad2 amx2ad1 amx2ad0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 amx2ad3-0 single-ended measurement amx2ad3-0 differential measurement 0000 ain2.0 ain01ic = 0 0000 +(ain2.0) -(ain2.1) ain01ic = 1 0001 ain2.1 0001 +(ain2.1) -(ain2.0) 0010 ain2.2 ain23ic = 0 0010 +(ain2.2) -(ain2.3) ain23ic = 1 0011 ain2.3 0011 +(ain2.3) -(ain2.2) 0100 ain2.4 ain45ic = 0 0100 +(ain2.4) -(ain2.5) ain45ic = 1 0101 ain2.5 0101 +(ain2.5) -(ain2.4) 0110 ain2.6 ain67ic = 0 0110 +(ain2.6) -(ain2.7) ain67ic = 1 0111 ain2.7 0111 +(ain2.7) -(ain2.6) 1xxx temperature sensor 1xxx -
page 90 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 7.7. adc2cf: adc2 configuration register bits7-3: ad2sc4-0: adc2 sar conversion clock period bits. sar conversion clock is derived from system clock by the following equation,where ad2sc refers to the 5-bit value held in bits ad2sc4-0. sar conversion clock requirements are given in table 7.1. bit2: ad2ljst: adc2 left justify select. 0: data in adc2h:adc2l registers are right-justified. 1: data in adc2h:adc2l registers are left-justified. bits1-0: unused. read = 00b; write = dont care. sfr page: sfr address: 2 0xbc r/wr/wr/wr/wr/wr/wr/wr/wresetvalue ad2sc4 ad2sc3 ad2sc2 ad2sc1 ad2sc0 ad2ljst - - 11111000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 ad2sc sysclk clk sar --------------------- -1 C =
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 91 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 7.8. adc2h: adc2 data word msb register bits7-0: adc2 data word high-order bits. for ad2ljst = 0: bits 7-2 are the sign extension of bit 1. bits 1-0 are the upper 2 bits of the 10-bit adc2 data word. for ad2ljst = 1: bits 7-0 are the most-significant bits of the 10-bit adc2 data word. sfr page: sfr address: 2 0xbf r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 7.9. adc2l: adc2 data word lsb register bits7-0: adc2 data word low-order bits. for ad2ljst = 0: bits 7-0 are the lower 8 bits of the 10-bit data word. for ad2ljst = 1: bits 7-6 are the lower 2 bits of the 10-bit data word. bits 5-0 will always read 0. sfr page: sfr address: 2 0xbe r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
page 92 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 7.10. adc2cn: adc2 control register bit 7: ad2en: adc2 enable bit. 0: adc2 disabled. adc2 is in low-power shutdown. 1: adc2 enabled. adc2 is active and ready for data conversions. bit6: ad2tm: adc2 track mode bit. 0: normal track mode: when adc2 is enabled,tracking is continuous unless a conversion is in progress. 1: low-power track mode: tracking defined by ad2cm2-0 bits (see below). bit5: ad2int: adc2 conversion complete interrupt flag. 0: adc2 has not completed a data conversion since the last time ad2int was cleared. 1: adc2 has completed a data conversion. bit 4: ad2busy: adc2 busy bit. read: 0: adc2 conversion is complete or a conversion is not currently in progress. ad2int is set to logic 1 on the falling edge of ad2busy. 1: adc2 conversion is in progress. write: 0: no effect. 1: initiates adc2 conversion if ad2cm2-0 = 000b bits 3-2: ad2cm1-0: adc2 start of conversion mode select. when ad2tm = 0: 00: adc2 conversion initiated on every write of 1 to ad2busy. 01: adc2 conversion initiated on overflow of timer 3. 10: adc2 conversion initiated on rising edge of external cnvstr2 pin. 11: adc2 conversion initiated on overflow of timer 2. when ad2tm = 1: 00: tracking initiated on write of 1 to ad2busy and lasts 3 sar clocks,followed by conversion. 01: tracking initiated on overflow of timer 3 and lasts 3 sar clocks,followed by conversion. 10: adc2 tracks only when cnvstr2 input is logic low; conversion starts on rising cnvstr2 edge. 11: tracking initiated on overflow of timer 2 and lasts 3 sar clocks,followed by conversion. bit 1: ad2wint: adc2 window compare interrupt flag. 0: adc2 window comparison data match has not occurred since this flag was last cleared. 1: adc2 window comparison data match has occurred. bit 0: ad2ljst: adc2 left justify select. 0: data in adc2h:adc2l registers are right-justified. 1: data in adc2h:adc2l registers are left-justified. sfr page: sfr address: 2 0xe8 (bit addressable) r/wr/wr/wr/wr/wr/wr/wr/wresetvalue ad2en ad2tm ad2int ad2busy ad2cm1 ad2cm0 ad2wint ad2ljst 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 93 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 7.3. programmable window detector the adc programmable window detector continuously compares the adc2 output registers to user-programmed limits,and notifies the system when a desired condition is detected. this is especially effective in an interrupt-driven system,saving code space and cpu bandwidth while delivering faster system response times. the window detector interrupt flag (ad2wint in register adc2cn) can also be used in polled mode. the adc2 greater-than (adc2gth,adc2gtl) and less-than (adc2lth,adc2ltl) registers hold the comparison values. the window detector flag can be programmed to indicate when measured data is inside or outside of the user-programmed limits, depending on the contents of the adc2 less-than and adc2 greater-than registers. figure 7.11. adc2gth: adc2 greater-than data high byte register bits7-0: high byte of adc2 greater-than data word. sfr page: sfr address: 2 0xc5 r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 7.12. adc2gtl: adc2 greater-than data low byte register bits7-0: low byte of adc2 greater-than data word. sfr page: sfr address: 2 0xc4 r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
page 94 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 7.13. adc2lth: adc2 less-than data high byte register bits7-0: high byte of adc2 less-than data word. sfr page: sfr address: 2 0xc7 r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 7.14. adc2ltl: adc2 less-than data low byte register bits7-0: low byte of adc2 less-than data word. sfr page: sfr address: 2 0xc6 r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 95 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 7.3.1. window detector in single-ended mode figure 7.15 shows two example window comparisons for right-justified,single-ended data,with adc2lth:adc2ltl = 0x0080 (128d) and adc2gth:adc2gtl = 0x0040 (64d). in single-ended mode,the input voltage can range from 0 to vref * (1023/1024) with respect to agnd,and is represented by a 10-bit unsigned integer value. in the left example,an ad2wint interrupt will be generated if the adc2 conversion word (adc2h:adc2l) is within the range defined by adc2gth:adc2gtl and adc2lth:adc2ltl (if 0x0040 < adc2h:adc2l < 0x0080). in the right example,and ad2wint interrupt will be generated if the adc2 conversion word is outside of the range defined by the adc2gt and adc2lt registers (if adc2h:adc2l < 0x0040 or adc2h:adc2l > 0x0080). figure 7.16 shows an example using left-justified data with the same comparison values. 0x03ff 0x0081 0x0080 0x007f 0x0041 0x0040 0x003f 0x0000 0 input voltage (p1.x- agnd) vref x(1023/1024) vref x(128/1024) vref x(64/1024) ad2wint=1 ad2wint not affected ad2wint not affected adc2lth:adc2ltl adc2gth:adc2gtl 0x03ff 0x0081 0x0080 0x007f 0x0041 0x0040 0x003f 0x0000 0 input voltage (p1.x- agnd) vref x(1023/1024) vref x(128/1024) vref x(64/1024) ad2wint not affected adc2lth:adc2ltl adc2gth:adc2gtl ad2wint=1 ad2wint=1 adc2h:adc2l adc2h:adc2l figure 7.15. adc window compare example: right-justified single-ended data 0xffc0 0x2040 0x2000 0x1fc0 0x1040 0x1000 0x0fc0 0x0000 0 input voltage (p1.x- agnd) vref x(1023/1024) vref x(128/1024) vref x(64/1024) ad2wint=1 ad2wint not affected ad2wint not affected adc2lth:adc2ltl adc2gth:adc2gtl 0xffc0 0x2040 0x2000 0x1fc0 0x1040 0x1000 0x0fc0 0x0000 0 input voltage (p1.x- agnd) vref x(1023/1024) vref x(128/1024) vref x(64/1024) ad2wint not affected adc2lth:adc2ltl adc2gth:adc2gtl ad2wint=1 ad2wint=1 adc2h:adc2l adc2h:adc2l figure 7.16. adc window compare example: left-justified single-ended data
page 96 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 7.3.2. window detector in differential mode figure 7.17 shows two example window comparisons for right-justified,differential data,with adc2lth:adc2ltl = 0x0040 (+64d) and adc2gth:adc2gth = 0xffff (-1d). in differential mode,the mea- surable voltage between the input pins is between -vref and vref*(511/512). output codes are represented as 10- bit 2s complement signed integers. in the left example,an ad2wint interrupt will be generated if the adc2 con- version word (adc2h:adc2l) is within the range defined by adc2gth:adc2gtl and adc2lth:adc2ltl (if 0xffff (-1d) < adc2h:adc2l < 0x0040 (64d)). in the right example,an ad2wint interrupt will be generated if the adc2 conversion word is outside of the range defined by the adc2gt and adc2lt registers (if adc2h:adc2l < 0xffff (-1d) or adc2h:adc2l > 0x0040 (+64d)). figure 7.18 shows an example using left-justified data with the same comparison values. 0x01ff 0x0041 0x0040 0x003f 0x0000 0xffff 0xfffe 0x0200 -vref input voltage (p1.x- p1.y) vref x(511/512) vref x(64/512) vref x(-1/512) 0x01ff 0x0041 0x0040 0x003f 0x0000 0xffff 0xfffe 0x0200 -vref input voltage (p1.x- p1.y) vref x(511/512) vref x(64/512) vref x(-1/512) ad2wint=1 ad2wint not affected ad2wint not affected adc2lth:adc2ltl adc2gth:adc2gtl ad2wint not affected adc2lth:adc2ltl adc2gth:adc2gtl ad2wint=1 ad2wint=1 adc2h:adc2l adc2h:adc2l figure 7.17. adc window compare example: right-justified differential data 0x7fc0 0x1040 0x1000 0x0fc0 0x0000 0xffc0 0xff80 0x8000 -vref input voltage (p1.x- p1.y) vref x(511/512) vref x(64/512) vref x(-1/512) 0x7fc0 0x1040 0x1000 0x0fc0 0x0000 0xffc0 0xff80 0x8000 -vref input voltage (p1.x- p1.y) vref x(511/512) vref x(64/512) vref x(-1/512) ad2wint=1 ad2wint not affected ad2wint not affected adc2lth:adc2ltl adc2gth:adc2gtl ad2wint not affected adc2lth:adc2ltl adc2gth:adc2gtl ad2wint=1 ad2wint=1 adc2h:adc2l adc2h:adc2l figure 7.18. adc window compare example: left-justified differential data
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 97 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information table 7.1. adc2 electrical characteristics vdd = 3.0 v,vref = 2.40 v (refsl=0),pga gain = 1,-40c to +85c unless otherwise specified parameter conditions min typ max units dc accuracy resolution 10 bits integral nonlinearity 0.5 1 lsb differential nonlinearity guaranteed monotonic 0.5 1 lsb offset error -12 1 12 lsb full scale error differential mode -15 -5 5 lsb offset temperature coefficient 3.6 ppm/c dynamic performance (10 khz sine-wave differential input, 1 db below full scale, 200 ksps) signal-to-noise plus distortion 53 55.5 db total harmonic distortion up to the 5 th harmonic -67 db spurious-free dynamic range 78 db conversion rate sar conversion clock 3 mhz conversion time in sar clocks 10 clocks track/hold acquisition time 300 ns throughput rate 200 ksps analog inputs input voltage range 0 vref v input capacitance 5 pf power specifications power supply current (vdd sup- plied to adc2) operating mode,200 ksps 400 900 a power supply rejection 0.3 mv/v
page 98 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n notes
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 99 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 8. dacs, 12-bit voltage mode (dac0 and dac1) each c8051f06x device includes two on-chip 12-bit voltage-mode digital-to-analog converters (dacs). each dac has an output swing of 0 v to (vref-1lsb) for a corresponding input code range of 0x000 to 0xfff. the dacs may be enabled/disabled via their corresponding control registers,dac0cn and dac1cn. while disabled, the dac output is maintained in a high-impedance state,and the dac supply current falls to 1 a or less. the volt- age reference for each dac is supplied at the vrefd pin (C8051F060/2 devices) or the vref2 pin (c8051f061/3 devices). see section 9. voltage reference 2 (C8051F060/2) on page 107 or section 10. voltage reference 2 (c8051f061/3) on page 109 for more information on configuring the voltage reference for the dacs. note that the biase bit described in the voltage reference sections must be set to 1 to use the dacs. dac0 av+ 12 agnd 8 8 ref dac0 dac0cn dac0en dac0md1 dac0md0 dac0df2 dac0df1 dac0df0 dac0h dac0l dig. mux latch latch 8 8 dac1 av+ 12 agnd 8 8 ref dac1 dac1cn dac1en dac1md1 dac1md0 dac1df2 dac1df1 dac1df0 dac1h dac1l dig. mux latch latch 8 8 dac0h timer 3 timer 4 timer 2 dac1h timer 3 timer 4 timer 2 figure 8.1. dac functional block diagram
page 100 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 8.1. dac output scheduling each dac features a flexible output update mechanism which allows for seamless full-scale changes and supports jitter-free updates for waveform generation. the following examples are written in terms of dac0,but dac1 opera- tion is identical. 8.1.1. update output on-demand in its default mode (dac0cn.[4:3] = 00) the dac0 output is updated on-demand on a write to the high-byte of the dac0 data register (dac0h). it is important to note that writes to dac0l are held,and have no effect on the dac0 output until a write to dac0h takes place. if writing a full 12-bit word to the dac data registers,the 12-bit data word is written to the low byte (dac0l) and high byte (dac0h) data registers. data is latched into dac0 after a write to the corresponding dac0h register, so the write sequence should be dac0l followed by dac0h if the full 12-bit resolution is required. the dac can be used in 8-bit mode by initializing dac0l to the desired value (typ- ically 0x00),and writing data to only dac0h (also see section 8.2 for information on formatting the 12-bit dac data word within the 16-bit sfr space). 8.1.2. update output based on timer overflow similar to the adc operation,in which an adc conversion can be initiated by a timer overflow independently of the processor,the dac outputs can use a timer overflow to schedule an output update event. this feature is useful in systems where the dac is used to generate a waveform of a defined sampling rate by eliminating the effects of vari- able interrupt latency and instruction execution on the timing of the dac output. when the dac0md bits (dac0cn.[4:3]) are set to 01,10,or 11,writes to both dac data registers (dac0l and dac0h) are held until an associated timer overflow event (timer 3,timer 4,or timer 2,respectively) occurs,at which time the dac0h:dac0l contents are copied to the dac input latches allowing the dac output to change to the new value. 8.2. dac output scaling/justification in some instances,input data should be shifted prior to a dac0 write operation to properly justify data within the dac input registers. this action would typically require one or more load and shift operations,adding software over- head and slowing dac throughput. to alleviate this problem,the data-formatting feature provides a means for the user to program the orientation of the dac0 data word within data registers dac0h and dac0l. the three dac0df bits (dac0cn.[2:0]) allow the user to specify one of five data word orientations as shown in the dac0cn register definition. dac1 is functionally the same as dac0 described above. the electrical specifications for both dac0 and dac1 are given in table 8.1.
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 101 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 8.2. dac0h: dac0 high byte register bits7-0: dac0 data word most significant byte. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd3 0 figure 8.3. dac0l: dac0 low byte register bits7-0: dac0 data word least significant byte. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd2 0
page 102 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 8.4. dac0cn: dac0 control register bit7: dac0en: dac0 enable bit. 0: dac0 disabled. dac0 output pin is disabled; dac0 is in low-power shutdown mode. 1: dac0 enabled. dac0 output pin is active; dac0 is operational. bits6-5: unused. read = 00b; write = dont care. bits4-3: dac0md1-0: dac0 mode bits. 00: dac output updates occur on a write to dac0h. 01: dac output updates occur on timer 3 overflow. 10: dac output updates occur on timer 4 overflow. 11: dac output updates occur on timer 2 overflow. bits2-0: dac0df2-0: dac0 data format bits: 000: the most significant nibble of the dac0 data word is in dac0h[3:0],while the least significant byte is in dac0l. 001: the most significant 5-bits of the dac0 data word is in dac0h[4:0],while the least significant 7-bits are in dac0l[7:1]. 010: the most significant 6-bits of the dac0 data word is in dac0h[5:0],while the least significant 6-bits are in dac0l[7:2]. 011: the most significant 7-bits of the dac0 data word is in dac0h[6:0],while the least significant 5-bits are in dac0l[7:3]. 1xx: the most significant 8-bits of the dac0 data word is in dac0h[7:0],while the least significant 4-bits are in dac0l[7:4]. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue dac0en - - dac0md1 dac0md0 dac0df2 dac0df1 dac0df0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd4 0 dac0h dac0l msb lsb dac0h dac0l msb lsb dac0h dac0l msb lsb dac0h dac0l msb lsb dac0h dac0l msb lsb
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 103 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 8.5. dac1h: dac1 high byte register bits7-0: dac1 data word most significant byte. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd3 1 figure 8.6. dac1l: dac1 low byte register bits7-0: dac1 data word least significant byte. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd2 1
page 104 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 8.7. dac1cn: dac1 control register bit7: dac1en: dac1 enable bit. 0: dac1 disabled. dac1 output pin is disabled; dac1 is in low-power shutdown mode. 1: dac1 enabled. dac1 output pin is active; dac1 is operational. bits6-5: unused. read = 00b; write = dont care. bits4-3: dac1md1-0: dac1 mode bits: 00: dac output updates occur on a write to dac1h. 01: dac output updates occur on timer 3 overflow. 10: dac output updates occur on timer 4 overflow. 11: dac output updates occur on timer 2 overflow. bits2-0: dac1df2: dac1 data format bits: 000: the most significant nibble of the dac1 data word is in dac1h[3:0],while the least significant byte is in dac1l. 001: the most significant 5-bits of the dac1 data word is in dac1h[4:0],while the least significant 7-bits are in dac1l[7:1]. 010: the most significant 6-bits of the dac1 data word is in dac1h[5:0],while the least significant 6-bits are in dac1l[7:2]. 011: the most significant 7-bits of the dac1 data word is in dac1h[6:0],while the least significant 5-bits are in dac1l[7:3]. 1xx: the most significant 8-bits of the dac1 data word is in dac1h[7:0],while the least significant 4-bits are in dac1l[7:4]. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue dac1en - - dac1md1 dac1md0 dac1df2 dac1df1 dac1df0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd4 1 dac1h dac1l msb lsb dac1h dac1l msb lsb dac1h dac1l msb lsb dac1h dac1l msb lsb dac1h dac1l msb lsb
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 105 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information . table 8.1. dac electrical characteristics vdd = 3.0 v,av+ = 3.0 v,vref = 2.40 v (refbe = 0),no output load unless otherwise specified parameter conditions min typ max units static performance resolution 12 bits integral nonlinearity 1.5 lsb differential nonlinearity 1 lsb output noise no output filter 100 khz output filter 10 khz output filter 250 128 41 vrms offset error data word = 0x014 3 30 mv offset tempco 6 ppm/c gain error 20 60 mv gain-error tempco 10 ppm/c vdd power supply rejection ratio -60 db output impedance in shutdown mode dacnen = 0 100 k ? output sink current 300 a output short-circuit current data word = 0xfff 15 ma dynamic performance voltage output slew rate load = 40pf 0.44 v/s output settling time to 1/2 lsb load = 40pf,output swing from code 0xfff to 0x014 10 s output voltage swing 0 vref- 1lsb v startup time 10 s analog outputs load regulation i l = 0.01ma to 0.3ma at code 0xfff 60 ppm power consumption (each dac) power supply current (av+ sup- plied to dac) data word = 0x7ff 300 500 a
page 106 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n notes
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 107 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 9. voltage reference 2 (C8051F060/2) the voltage reference circuitry offers full flexibility in operating the adc2 and dac modules. two voltage refer- ence input pins allow adc2 and the two dacs to reference an external voltage reference or the on-chip voltage ref- erence output. adc2 may also reference the analog power supply voltage,via the vref multiplexer shown in figure 9.1. the internal voltage reference circuit consists of a 1.2 v,temperature stable bandgap voltage reference generator and a gain-of-two output buffer amplifier. the internal reference may be routed via the vref pin to external system com- ponents or to the voltage reference input pins shown in figure 9.1. the maximum load seen by the vref pin must be less than 200 a to agnd. bypass capacitors of 0.1 f and 4.7 f are recommended from the vref pin to agnd, as shown in figure 9.1. the reference control register 2,ref2cn (defined in figure 9.2) enables/disables the internal reference generator and selects the reference input for adc2. the biase bit in ref2cn enables the on-board reference generator while the refbe bit enables the gain-of-two buffer amplifier which drives the vref pin. when disabled,the supply cur- rent drawn by the bandgap and buffer amplifier falls to less than 1 a (typical) and the output of the buffer amplifier enters a high impedance state. if the internal bandgap is used as the reference voltage generator,biase and refbe must both be set to logic 1. if the internal reference is not used,refbe may be set to logic 0. note that the biase bit must be set to logic 1 if adc2 or either dac is used,regardless of the voltage reference used. if neither adc2 nor the dacs are being used,both of these bits can be set to logic 0 to conserve power. bit ad2vrs selects between vref2 and av+ for the adc2 voltage reference source. the electrical specifications for the voltage reference are given in table 9.1. recommended bypass capacitors x2 vref dac0 dac1 ref vrefd av+ adc2 vref2 ref 1 0 4.7 f0.1 f ref2cn refbe biase tempe ad2vrs refbe biase bias to adc2, dacs 1.2v band-gap en external voltage reference circuit r vdd + figure 9.1. voltage reference functional block diagram
page 108 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n the temperature sensor connects to the highest order input of the adc2 input multiplexer (see section 7. 10-bit adc (adc2) on page 83 ). the tempe bit within ref2cn enables and disables the temperature sensor. while dis- abled,the temperature sensor defaults to a high impedance state,and any a/d measurements performed on the sensor while disabled result in meaningless data. table 9.1. voltage reference electrical characteristics vdd = 3.0 v,av+ = 3.0 v,-40c to +85c unless otherwise specified parameter conditions min typ max units internal reference (refbe = 1) output voltage 25c ambient 2.36 2.43 2.48 v vref short-circuit current 30 ma vref temperature coefficient 15 ppm/c load regulation load = 0 to 200 a to agnd 0.5 ppm/a vref turn-on time 1 4.7f tantalum,0.1f ceramic bypass 2 ms vref turn-on time 2 0.1f ceramic bypass 20 s vref turn-on time 3 no bypass cap 10 s external reference (refbe = 0) input voltage range 1.00 (av+) - 0.3 v input current 0 1 a figure 9.2. ref2cn: reference control register 2 bits7-4: unused. read = 0000b; write = dont care. bit3: ad2vrs: adc2 voltage reference select. 0: adc2 voltage reference from vref2 pin. 1: adc2 voltage reference from av+. bit2: tempe: temperature sensor enable bit. 0: internal temperature sensor off. 1: internal temperature sensor on. bit1: biase: adc/dac bias generator enable bit. (must be 1 if using adc2 or dacs). 0: internal bias generator off. 1: internal bias generator on. bit0: refbe: internal reference buffer enable bit. 0: internal reference buffer off. 1: internal reference buffer on. internal voltage reference is driven on the vref pin. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue - - - - ad2vrs tempe biase refbe 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd1 2
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 109 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 10. voltage reference 2 (c8051f061/3) the internal voltage reference circuit consists of a 1.2 v,temperature stable bandgap voltage reference generator and a gain-of-two output buffer amplifier. the internal reference may be routed via the vref pin to external system com- ponents or to the vref2 input pin shown in figure 10.1. the maximum load seen by the vref pin must be less than 200 a to agnd. bypass capacitors of 0.1 f and 4.7 f are recommended from the vref pin to agnd,as shown in figure 10.1. the vref2 pin provides a voltage reference input for adc2 and the dacs. adc2 may also reference the analog power supply voltage,via the vref multiplexers shown in figure 10.1. the reference control register 2,ref2cn (defined in figure 10.2) enables/disables the internal reference generator and selects the reference input for adc2. the biase bit in ref2cn enables the on-board reference generator while the refbe bit enables the gain-of-two buffer amplifier which drives the vref pin. when disabled,the supply cur- rent drawn by the bandgap and buffer amplifier falls to less than 1 a (typical) and the output of the buffer amplifier enters a high impedance state. if the internal bandgap is used as the reference voltage generator,biase and refbe must both be set to logic 1. if the internal reference is not used,refbe may be set to logic 0. note that the biase bit must be set to logic 1 if adc2 or either dac is used,regardless of the voltage reference used. if neither adc2 nor the dacs are being used,both of these bits can be set to logic 0 to conserve power. bit ad2vrs selects between vref2 and av+ for the adc2 voltage reference source. the electrical specifications for the voltage reference are given in table 10.1. recommended bypass capacitors x2 vref dac0 dac1 ref av+ adc2 ref 1 0 vref2 4.7 f0.1 f ref2cn refbe biase tempe ad2vrs refbe biase bias to adc2, dacs 1.2v band-gap en external voltage reference circuit r vdd + figure 10.1. voltage reference functional block diagram
page 110 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n the temperature sensor connects to the highest order input of the adc2 input multiplexer (see section 7. 10-bit adc (adc2) on page 83 ). the tempe bit within ref2cn enables and disables the temperature sensor. while dis- abled,the temperature sensor defaults to a high impedance state,and any a/d measurements performed on the sensor while disabled result in meaningless data. table 10.1. voltage reference electrical characteristics vdd = 3.0 v,av+ = 3.0 v,-40c to +85c unless otherwise specified parameter conditions min typ max units internal reference (refbe = 1) output voltage 25c ambient 2.36 2.43 2.48 v vref short-circuit current 30 ma vref temperature coefficient 15 ppm/c load regulation load = 0 to 200 a to agnd 0.5 ppm/a vref turn-on time 1 4.7f tantalum,0.1f ceramic bypass 2 ms vref turn-on time 2 0.1f ceramic bypass 20 s vref turn-on time 3 no bypass cap 10 s external reference (refbe = 0) input voltage range 1.00 (av+) - 0.3 v input current 0 1 a figure 10.2. ref2cn: reference control register 2 bits7-4: unused. read = 0000b; write = dont care. bit3: ad2vrs: adc2 voltage reference select. 0: adc2 voltage reference from vref2 pin. 1: adc2 voltage reference from av+. bit2: tempe: temperature sensor enable bit. 0: internal temperature sensor off. 1: internal temperature sensor on. bit1: biase: adc/dac bias generator enable bit. (must be 1 if using adc2 or dacs). 0: internal bias generator off. 1: internal bias generator on. bit0: refbe: internal reference buffer enable bit. 0: internal reference buffer off. 1: internal reference buffer on. internal voltage reference is driven on the vref pin. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue - - - - ad2vrs tempe biase refbe 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd1 2
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 111 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 11. comparators c8051f06x family of devices include three on-chip programmable voltage comparators,shown in figure 11.1. each comparator offers programmable response time and hysteresis. when assigned to a port pin,the comparator output may be configured as open drain or push-pull,and comparator inputs should be configured as analog inputs (see sec- tion 17.1.5. configuring port 1 and 2 pins as analog inputs on page 195 ). the comparator may also be used as a reset source (see section 13.5. comparator0 reset on page 157 ). the output of a comparator can be polled by software,used as an interrupt source,used as a reset source,and/or routed to a port pin. each comparator can be individually enabled and disabled (shutdown). when disabled,the com- parator output (if assigned to a port i/o pin via the crossbar) defaults to the logic low state,and its supply current fallstolessthan1a.see section 17.1.1. crossbar pin assignment and allocation on page 193 for details on configuring the comparator output via the digital crossbar. the comparator inputs can be externally driven from -0.25 v to (vdd) + 0.25 v without damage or upset. the complete electrical specifications for the comparator are given in table 11.1. figure 11.1. comparator functional block diagram vdd cptncn reset decision tree + - crossbar interrupt logic q q set clr d q q set clr d (synchronizer) cpn + cpn - cpnen cpnout cpnrif cpnfif cpnhyp1 cpnhyp0 cpnhyn1 cpnhyn0 cptnmd cpnrie cpnfie cpnmd1 cpnmd0 cpn rising-edge interrupt flag cpn falling-edge interrupt flag cpn cp0 + cp0 - cp1 + cp1 - cp2 + cp2 - p2.6 p2.7 p2.2 p2.3 p2.4 p2.5 comparator pin assignments gnd cpn interrupt
page 112 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n the comparator response time may be configured in software using the cpnmd1-0 bits in register cptnmd (see figure 11.4). selecting a longer response time reduces the amount of power consumed by the comparator. see table 11.1 for complete timing and current consumption specifications. the hysteresis of the comparator is software-programmable via its comparator control register (cptncn). the user can program both the amount of hysteresis voltage (referred to the input voltage) and the positive and negative- going symmetry of this hysteresis around the threshold voltage. the comparator hysteresis is programmed using bits3-0 in the comparator control register cptncn (shown in figure 11.3). the amount of negative hysteresis voltage is determined by the settings of the cpnhyn bits. as shown in figure 11.2,the negative hysteresis can be programmed to three different settings,or negative hysteresis can be disabled. in a similar way,the amount of positive hysteresis is determined by the setting the cpnhyp bits. positive hysteresis voltage (programmed with cpnhyp bits) negative hysteresis voltage (programmed by cpnhyn bits) vin- vin+ inputs circuit configuration + _ cpn+ cpn- cpn vin+ vin- out v oh positive hysteresis disabled maximum positive hysteresis negative hysteresis disabled maximum negative hysteresis output v ol figure 11.2. comparator hysteresis plot
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 113 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information comparator interrupts can be generated on either rising-edge and falling-edge output transitions. (for interrupt enable and priority control,see section 12.3. interrupt handler on page 143 ). the rising and/or falling -edge interrupts are enabled using the comparators rising/falling edge interrupt enable bits (cpnrie and cpnfie) in their respective comparator mode selection register (cptnmd),shown in figure 11.4. these bits allow the user to control which edge (or both) will cause a comparator interrupt. however,the comparator interrupt must also be enabled in the extended interrupt enable register (eie1). the cpnfif flag is set to logic 1 upon a comparator fall- ing-edge interrupt,and the cpnrif flag is set to logic 1 upon the comparator rising-edge interrupt. once set,these bits remain set until cleared by software. the output state of a comparator can be obtained at any time by reading the cpnout bit. a comparator is enabled by setting its respective cpnen bit to logic 1,and is disabled by clearing this bit to logic 0.upon enabling a comparator,the output of the comparator is not immediately valid. before using a com- parator as an interrupt or reset source,software should wait for a minimum of the specified power-up time as spec- ified in table 11.1,comparator electrical characteristics, on page 116. 11.1. comparator inputs the port pins selected as comparator inputs should be configured as analog inputs in the port 2 input configuration register (for details on port configuration,see section 17.1.3. configuring port pins as digital inputs on page 195 ). the inputs for comparator are on port 2 as follows: comparator input port pin cp0 + p2.6 cp0 - p2.7 cp1 + p2.2 cp1 - p2.3 cp2 + p2.4 cp2 - p2.5
page 114 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 11.3. cptncn: comparator 0, 1, and 2 control register bit7: cpnen: comparator enable bit. (please see note below.) 0: comparator disabled. 1: comparator enabled. bit6: cpnout: comparator output state flag. 0: voltage on cpn+ < cpn-. 1: voltage on cpn+ > cpn-. bit5: cpnrif: comparator rising-edge interrupt flag. 0: no comparator rising edge interrupt has occurred since this flag was last cleared. 1: comparator rising edge interrupt has occurred. must be cleared by software. bit4: cpnfif: comparator falling-edge interrupt flag. 0: no comparator falling-edge interrupt has occurred since this flag was last cleared. 1: comparator falling-edge interrupt has occurred. must be cleared by software. bits3-2: cpnhyp1-0: comparator positive hysteresis control bits. 00: positive hysteresis disabled. 01: positive hysteresis = 5 mv. 10: positive hysteresis = 10 mv. 11: positive hysteresis = 20 mv. bits1-0: cpnhyn1-0: comparator negative hysteresis control bits. 00: negative hysteresis disabled. 01: negative hysteresis = 5 mv. 10: negative hysteresis = 10 mv. 11: negative hysteresis = 20 mv. note: upon enabling a comparator,the output of the comparator is not immediately valid. before using a comparator as an interrupt or reset source,software should wait for a minimum of the specified power-up time as specified in table 11.1,comparator electrical characteristics, on page 116. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue cpnen cpnout cpnrif cpnfif cpnhyp1 cpnhyp0 cpnhyn1 cpnhyn0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: cpt0cn: 0x88; cpt1cn: 0x88; cpt2cn: 0x88 sfr pages: cpt0cn: page 1; cpt1cn: page 2; cpt2cn: page 3
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 115 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 11.4. cptnmd: comparator mode selection register bits7-6: unused. read = 00b,write = dont care. bit 5: cpnrie: comparator rising-edge interrupt enable bit. 0: comparator rising-edge interrupt disabled. 1: comparator rising-edge interrupt enabled. bit 4: cpnfie: comparator falling-edge interrupt enable bit. 0: comparator falling-edge interrupt disabled. 1: comparator falling-edge interrupt enabled. bits3-2: unused. read = 00b,write = dont care. bits1-0: cpnmd1-cpnmd0: comparator mode select these bits select the response time for the comparator. r/wr/wr/wr/w r r r/wr/wresetvalue - - cpnrie cpnfie - - cpnmd1 cpnmd0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: cpt0md: 0x89; cpt1md: 0x89; cpt2md: 0x89 sfr page: cpt0md: page 1; cpt1md: page 2; cpt2md: page 3 mode cpnmd1 cpnmd0 notes 0 0 0 fastest response time 101 - 210 - 3 1 1 lowest power consumption
page 116 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n table 11.1. comparator electrical characteristics vdd = 3.0 v,-40c to +85c unless otherwise specified. parameter conditions min typ max units response time, mode 0 cpn+ - cpn- = 100 mv 100 s cpn+ - cpn- = 10 mv 250 s response time, mode 1 cpn+ - cpn- = 100 mv 175 s cpn+ - cpn- = 10 mv 500 s response time, mode 2 cpn+ - cpn- = 100 mv 320 s cpn+ - cpn- = 10 mv 1100 s response time, mode 3 cpn+ - cpn- = 100 mv 1050 s cpn+ - cpn- = 10 mv 5200 s common-mode rejection ratio 1.5 4 mv/v positive hysteresis 1 cpnhyp1-0 = 00 0 1 mv positive hysteresis 2 cpnhyp1-0 = 01 3 5 7 mv positive hysteresis 3 cpnhyp1-0 = 10 7 10 15 mv positive hysteresis 4 cpnhyp1-0 = 11 15 20 25 mv negative hysteresis 1 cpnhyn1-0 = 00 0 1 mv negative hysteresis 2 cpnhyn1-0 = 01 3 5 7 mv negative hysteresis 3 cpnhyn1-0 = 10 7 10 15 mv negative hysteresis 4 cpnhyn1-0 = 11 15 20 25 mv inverting or non-inverting input voltage range -0.25 vdd + 0.25 v input capacitance 7 pf input bias current -5 0.001 +5 na inputoffsetvoltage -5 +5 mv power supply power supply rejection 0.1 1 mv/v power-up time 10 s supply current at dc mode 0 7.6 a mode 1 3.2 a mode 2 1.3 a mode 3 0.4 a
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 117 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 12. cip-51 microcontroller the mcu system controller core is the cip-51 microcontroller. the cip-51 is fully compatible with the mcs-51? instruction set; standard 803x/805x assemblers and compilers can be used to develop software. the mcu family has a superset of all the peripherals included with a standard 8051. included are five 16-bit counter/timers (see descrip- tion in section 23 ),two full-duplex uarts (see description in section 21 and section 22 ),256 bytes of internal ram,128 byte special function register (sfr) address space (see section 12.2.6 ),and 59/24 general-purpose i/o pins (see description in section 17 ). the cip-51 also includes on-chip debug hardware (see description in section 25 ),and interfaces directly with the mcus analog and digital subsystems providing a complete data acquisition or control-system solution in a single integrated circuit. the cip-51 microcontroller core implements the standard 8051 organization and peripherals as well as additional custom peripherals and functions to extend its capability (see figure 12.1 for a block diagram). the cip-51 includes the following features: figure 12.1. cip-51 block diagram data bus tmp1 tmp2 prgm. address reg. pc incrementer alu psw data bus data bus memory interface mem_address d8 pipeline buffer data pointer interrupt interface system_irqs debug_irq mem_control control logic a16 program counter (pc) stop clock reset idle power control register data bus sfr bus interface sfr_address sfr_control sfr_write_data sfr_read_data d8 d8 bregister d8 d8 accumulator d8 d8 d8 d8 d8 d8 d8 d8 mem_write_data mem_read_data d8 sram address register sram (256 x 8) d8 stack pointer d8 - fully compatible with mcs-51 instruction set - 25 mips peak throughput with 25 mhz clock - 0 to 25 mhz clock frequency - 256 bytes of internal ram - 59/24 general-purpose i/o pins - extended interrupt handler - reset input - power management modes - on-chip debug logic - program and data memory security
page 118 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n performance the cip-51 employs a pipelined architecture that greatly increases its instruction throughput over the standard 8051 architecture. in a standard 8051,all instructions except for mul and div take 12 or 24 system clock cycles to exe- cute,and usually have a maximum system clock of 12 mhz. by contrast,the cip-51 core executes 70% of its instruc- tions in one or two system clock cycles,with no instructions taking more than eight system clock cycles. with the cip-51's maximum system clock at 25 mhz,it has a peak throughput of 25 mips. the cip-51 has a total of 109 instructions. the table below shows the total number of instructions that require each execution time. programming and debugging support a jtag-based serial interface is provided for in-system programming of the flash program memory and commu- nication with on-chip debug support logic. the re-programmable flash can also be read and changed a single byte at a time by the application software using the movc and movx instructions. this feature allows program memory to be used for non-volatile data storage as well as updating program code under software control. the on-chip debug support logic facilitates full speed in-circuit debugging,allowing the setting of hardware break- points and watch points,starting,stopping and single stepping through program execution (including interrupt service routines),examination of the program's call stack,and reading/writing the contents of registers and memory. this method of on-chip debug is completely non-intrusive and non-invasive,requiring no ram,stack,timers,or other on-chip resources. the cip-51 is supported by development tools from cygnal integrated products and third party vendors. cygnal pro- vides an integrated development environment (ide) including editor,macro assembler,debugger and programmer. the ide's debugger and programmer interface to the cip-51 via its jtag interface to provide fast and efficient in- system device programming and debugging. third party macro assemblers and c compilers are also available. 12.1. instruction set the instruction set of the cip-51 system controller is fully compatible with the standard mcs-51? instruction set; standard 8051 development tools can be used to develop software for the cip-51. all cip-51 instructions are the binary and functional equivalent of their mcs-51? counterparts,including opcodes,addressing modes and effect on psw flags. however,instruction timing is different than that of the standard 8051. 12.1.1. instruction and cpu timing in many 8051 implementations,a distinction is made between machine cycles and clock cycles,with machine cycles varying from 2 to 12 clock cycles in length. however,the cip-51 implementation is based solely on clock cycle tim- ing. all instruction timings are specified in terms of clock cycles. due to the pipelined architecture of the cip-51,most instructions execute in the same number of clock cycles as there are program bytes in the instruction. conditional branch instructions take one less clock cycle to complete when the branch is not taken as opposed to when the branch is taken. table 12.1 is the cip-51 instruction set summary,which includes the mnemonic,number of bytes,and number of clock cycles for each instruction. 12.1.2. movx instruction and program memory in the cip-51,the movx instruction serves three purposes: accessing on-chip xram,accessing off-chip xram, and accessing on-chip program flash memory. the flash access feature provides a mechanism for user software to update program code and use the program memory space for non-volatile data storage (see section 15. flash clocks to execute 1 22/333/444/55 8 number of instructions 265051473121
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 119 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information memory on page 167 ). the external memory interface provides a fast access to off-chip xram (or memory- mapped peripherals) via the movx instruction. refer to section 16. external data memory inter- face and on-chip xram on page 175 for details. table 12.1. cip-51 instruction set summary mnemonic description bytes clock cycles arithmetic operations add a,rn add register to a 1 1 add a,direct add direct byte to a 2 2 add a,@ri add indirect ram to a 1 2 add a,#data add immediate to a 2 2 addc a,rn add register to a with carry 1 1 addc a,direct add direct byte to a with carry 2 2 addc a,@ri add indirect ram to a with carry 1 2 addc a,#data add immediate to a with carry 2 2 subb a,rn subtract register from a with borrow 1 1 subb a,direct subtract direct byte from a with borrow 2 2 subb a,@ri subtract indirect ram from a with borrow 1 2 subb a,#data subtract immediate from a with borrow 2 2 inc a increment a 1 1 inc rn increment register 1 1 inc direct increment direct byte 2 2 inc @ri increment indirect ram 1 2 dec a decrement a 1 1 dec rn decrement register 1 1 dec direct decrement direct byte 2 2 dec @ri decrement indirect ram 1 2 inc dptr increment data pointer 1 1 mul ab multiply a and b 1 4 div ab divide a by b 1 8 da a decimal adjust a 1 1 logical operations anl a,rn and register to a 1 1 anl a,direct and direct byte to a 2 2 anl a,@ri and indirect ram to a 1 2 anl a,#data and immediate to a 2 2 anl direct,a and a to direct byte 2 2 anl direct,#data and immediate to direct byte 3 3 orl a,rn or register to a 1 1 orl a,direct or direct byte to a 2 2 orl a,@ri or indirect ram to a 1 2 orl a,#data or immediate to a 2 2 orl direct,a or a to direct byte 2 2 orl direct,#data or immediate to direct byte 3 3 xrl a,rn exclusive-or register to a 1 1 xrl a,direct exclusive-or direct byte to a 2 2 xrl a,@ri exclusive-or indirect ram to a 1 2
page 120 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n xrl a,#data exclusive-or immediate to a 2 2 xrl direct,a exclusive-or a to direct byte 2 2 xrl direct,#data exclusive-or immediate to direct byte 3 3 clr a clear a 1 1 cpl a complement a 1 1 rl a rotate a left 1 1 rlc a rotate a left through carry 1 1 rr a rotate a right 1 1 rrc a rotate a right through carry 1 1 swap a swap nibbles of a 1 1 data transfer mov a,rn move register to a 1 1 mov a,direct move direct byte to a 2 2 mov a,@ri move indirect ram to a 1 2 mov a,#data move immediate to a 2 2 mov rn,a move a to register 1 1 mov rn,direct move direct byte to register 2 2 mov rn,#data move immediate to register 2 2 mov direct,a move a to direct byte 2 2 mov direct,rn move register to direct byte 2 2 mov direct,direct move direct byte to direct byte 3 3 mov direct,@ri move indirect ram to direct byte 2 2 mov direct,#data move immediate to direct byte 3 3 mov @ri,a move a to indirect ram 1 2 mov @ri,direct move direct byte to indirect ram 2 2 mov @ri,#data move immediate to indirect ram 2 2 mov dptr,#data16 load dptr with 16-bit constant 3 3 movca,@a+dptr movecodebyterelativedptrtoa 1 3 movca,@a+pc movecodebyterelativepctoa 1 3 movx a,@ri move external data (8-bit address) to a 1 3 movx @ri,a move a to external data (8-bit address) 1 3 movx a,@dptr move external data (16-bit address) to a 1 3 movx @dptr,a move a to external data (16-bit address) 1 3 push direct push direct byte onto stack 2 2 pop direct pop direct byte from stack 2 2 xch a,rn exchange register with a 1 1 xch a,direct exchange direct byte with a 2 2 xch a,@ri exchange indirect ram with a 1 2 xchd a,@ri exchange low nibble of indirect ram with a 1 2 booleanmanipulation clr c clear carry 1 1 clr bit clear direct bit 2 2 setb c set carry 1 1 setb bit set direct bit 2 2 cpl c complement carry 1 1 table 12.1. cip-51 instruction set summary mnemonic description bytes clock cycles
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 121 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information cpl bit complement direct bit 2 2 anl c,bit and direct bit to carry 2 2 anl c,/bit and complement of direct bit to carry 2 2 orl c,bit or direct bit to carry 2 2 orl c,/bit or complement of direct bit to carry 2 2 mov c,bit move direct bit to carry 2 2 mov bit,c move carry to direct bit 2 2 jc rel jump if carry is set 2 2/3 jnc rel jump if carry is not set 2 2/3 jb bit,rel jump if direct bit is set 3 3/4 jnb bit,rel jump if direct bit is not set 3 3/4 jbc bit,rel jump if direct bit is set and clear bit 3 3/4 program branching acall addr11 absolute subroutine call 2 3 lcall addr16 long subroutine call 3 4 ret return from subroutine 1 5 reti return from interrupt 1 5 ajmp addr11 absolute jump 2 3 ljmp addr16 long jump 3 4 sjmp rel short jump (relative address) 2 3 jmp @a+dptr jump indirect relative to dptr 1 3 jz rel jump if a equals zero 2 2/3 jnz rel jump if a does not equal zero 2 2/3 cjne a,direct,rel compare direct byte to a and jump if not equal 3 3/4 cjne a,#data,rel compare immediate to a and jump if not equal 3 3/4 cjne rn,#data,rel compare immediate to register and jump if not equal 3 3/4 cjne @ri,#data,rel compare immediate to indirect and jump if not equal 3 4/5 djnz rn,rel decrement register and jump if not zero 2 2/3 djnz direct,rel decrement direct byte and jump if not zero 3 3/4 nop no operation 1 1 table 12.1. cip-51 instruction set summary mnemonic description bytes clock cycles
page 122 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n notes on registers, operands and addressing modes: rn - register r0-r7 of the currently selected register bank. @ri - data ram location addressed indirectly through r0 or r1. rel - 8-bit,signed (twos complement) offset relative to the first byte of the following instruction. used by sjmp and all conditional jumps. direct - 8-bit internal data locations address. this could be a direct-access data ram location (0x00-0x7f) or an sfr (0x80-0xff). #data - 8-bit constant #data16 - 16-bit constant bit - direct-accessed bit in data ram or sfr addr11 - 11-bit destination address used by acall and ajmp. the destination must be within the same 2k-byte page of program memory as the first byte of the following instruction. addr16 - 16-bit destination address used by lcall and ljmp. the destination may be anywhere within the 64k- byte program memory space. there is one unused opcode (0xa5) that performs the same function as nop. all mnemonics copyrighted ? intel corporation 1980.
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 123 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 12.2. memory organization the memory organization of the cip-51 system controller is similar to that of a standard 8051. there are two sepa- rate memory spaces: program memory and data memory. program and data memory share the same address space but are accessed via different instruction types. there are 256 bytes of internal data memory and 64k bytes of internal program memory address space implemented within the cip-51. the cip-51 memory organization is shown in figure 12.2. 12.2.1. program memory the cip-51 has a 64k byte program memory space. the mcu implements 65536 bytes of this program memory space as in-system re-programmed flash memory,organized in a contiguous block from addresses 0x0000 to 0xffff. note: 1024 bytes (0xfc00 to 0xffff) of this memory are reserved,and are not available for user program storage. program memory is normally assumed to be read-only. however,the cip-51 can write to program memory by setting the program store write enable bit (psctl.0) and using the movx instruction. this feature provides a mechanism for the cip-51 to update program code and use the program memory space for non-volatile data storage. refer to sec- tion 15. flash memory on page 167 for further details. 12.2.2. data memory the cip-51 implements 256 bytes of internal ram mapped into the data memory space from 0x00 through 0xff. the lower 128 bytes of data memory are used for general purpose registers and scratch pad memory. either direct or program/data memory (flash) (direct and indirect addressing) 0x00 0x7f upper 128 ram (indirect addressing only) 0x80 0xff special function registers (direct addressing only) data memory (ram) general purpose registers 0x1f 0x20 0x2f bit addressable lower 128 ram (direct and indirect addressing) 0x30 internal data address space external data address space xram - 4096 bytes (accessable using movx instruction) 0x0000 0x0fff off-chip xram space (C8051F060/2 only) 0x1000 0xffff flash (in-system programmable in 512 byte sectors) 0x0000 0xffff reserved 0xfc00 0xfbff scrachpad memory (data only) 0x1007f 0x10000 up to 256 sfr pages 1 3 0 2 figure 12.2. memory map
page 124 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n indirect addressing may be used to access the lower 128 bytes of data memory. locations 0x00 through 0x1f are addressable as four banks of general purpose registers,each bank consisting of eight byte-wide registers. the next 16 bytes,locations 0x20 through 0x2f,may either be addressed as bytes or as 128 bit locations accessible with the direct addressing mode. the upper 128 bytes of data memory are accessible only by indirect addressing. this region occupies the same address space as the special function registers (sfr) but is physically separate from the sfr space. the addressing mode used by an instruction when accessing locations above 0x7f determines whether the cpu accesses the upper 128 bytes of data memory space or the sfrs. instructions that use direct addressing will access the sfr space. instructions using indirect addressing above 0x7f access the upper 128 bytes of data memory. figure 12.2 illustrates the data memory organization of the cip-51. 12.2.3. general purpose registers the lower 32 bytes of data memory,locations 0x00 through 0x1f,may be addressed as four banks of general-purpose registers. each bank consists of eight byte-wide registers designated r0 through r7. only one of these banks may be enabled at a time. two bits in the program status word,rs0 (psw.3) and rs1 (psw.4),select the active register bank (see description of the psw in figure 12.16). this allows fast context switching when entering subroutines and inter- rupt service routines. indirect addressing modes use registers r0 and r1 as index registers. 12.2.4. bit addressable locations in addition to direct access to data memory organized as bytes,the sixteen data memory locations at 0x20 through 0x2f are also accessible as 128 individually addressable bits. each bit has a bit address from 0x00 to 0x7f. bit 0 of the byte at 0x20 has bit address 0x00 while bit 7 of the byte at 0x20 has bit address 0x07. bit 7 of the byte at 0x2f has bit address 0x7f. a bit access is distinguished from a full byte access by the type of instruction used (bit source or destination operands as opposed to a byte source or destination). the mcs-51? assembly language allows an alternate notation for bit addressing of the form xx.b where xx is the byte address and b is the bit position within the byte. for example,the instruction: mov c, 22.3h moves the boolean value at 0x13 (bit 3 of the byte at location 0x22) into the carry flag. 12.2.5. stack a programmer's stack can be located anywhere in the 256 byte data memory. the stack area is designated using the stack pointer (sp,address 0x81) sfr. the sp will point to the last location used. the next value pushed on the stack is placed at sp+1 and then sp is incremented. a reset initializes the stack pointer to location 0x07; therefore,the first value pushed on the stack is placed at location 0x08,which is also the first register (r0) of register bank 1. thus,if more than one register bank is to be used,the sp should be initialized to a location in the data memory not being used for data storage. the stack depth can extend up to 256 bytes. the mcus also have built-in hardware for a stack record which is accessed by the debug logic. the stack record is a 32-bit shift register,where each push or increment sp pushes one record bit onto the register,and each call pushes two record bits onto the register. (a pop or decrement sp pops one record bit,and a ret pops two record bits,also.) the stack record circuitry can also detect an overflow or underflow on the 32-bit shift register,and can notify the debug software even with the mcu running at speed.
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 125 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 12.2.6. special function registers the direct-access data memory locations from 0x80 to 0xff constitute the special function registers (sfrs). the sfrs provide control and data exchange with the cip-51's resources and peripherals. the cip-51 duplicates the sfrs found in a typical 8051 implementation as well as implementing additional sfrs used to configure and access the sub-systems unique to the mcu. this allows the addition of new functionality while retaining compatibility with the mcs-51? instruction set. table 12.2 lists the sfrs implemented in the cip-51 system controller. the sfr registers are accessed whenever the direct addressing mode is used to access memory locations from 0x80 to 0xff. sfrs with addresses ending in 0x0 or 0x8 (e.g. p0,tcon,p1,scon,ie,etc.) are bit-addressable as well as byte-addressable. all other sfrs are byte-addressable only. unoccupied addresses in the sfr space are reserved for future use. accessing these areas will have an indeterminate effect and should be avoided. refer to the corre- sponding pages of the datasheet,as indicated in table 12.3,for a detailed description of each register. 12.2.6.1. sfr paging the cip-51 features sfr paging, allowing the device to map many sfrs into the 0x80 to 0xff memory address space. the sfr memory space has 256 pages . in this way,each memory location from 0x80 to 0xff can access up to 256 sfrs. the c8051f06x family of devices utilizes five sfr pages: 0,1,2,3,and f. sfr pages are selected using the special function register page selection register,sfrpage (see figure 12.10). the procedure for reading and writing an sfr is as follows: 1. select the appropriate sfr page number using the sfrpage register. 2. use direct accessing mode to read or write the special function register (mov instruction). 12.2.6.2. interrupts and sfr paging when an interrupt occurs,the sfr page register will automatically switch to the sfr page containing the flag bit that caused the interrupt. the automatic sfr page switch function conveniently removes the burden of switching sfr pages from the interrupt service routine. upon execution of the reti instruction,the sfr page is automatically restored to the sfr page in use prior to the interrupt. this is accomplished via a three-byte sfr page stack .thetop byte of the stack is sfrpage,the current sfr page. the second byte of the sfr page stack is sfrnext. the third, or bottom byte of the sfr page stack is sfrlast. on interrupt,the current sfrpage value is pushed to the sfrn- ext byte,and the value of sfrnext is pushed to sfrlast. hardware then loads sfrpage with the sfr page containing the flag bit associated with the interrupt. on a return from interrupt,the sfr page stack is popped result- ing in the value of sfrnext returning to the sfrpage register,thereby restoring the sfr page context without software intervention. the value in sfrlast (0x00 if there is no sfr page value in the bottom of the stack) of the stack is placed in sfrnext register. if desired,the values stored in sfrnext and sfrlast may be modified dur- ing an interrupt,enabling the cpu to return to a different sfr page upon execution of the reti instruction (on inter- rupt exit). modifying registers in the sfr page stack does not cause a push or pop of the stack. only interrupt calls and returns will cause push/pop operations on the sfr page stack.
page 126 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n automatic hardware switching of the sfr page on interrupts may be enabled or disabled as desired using the sfr automatic page control enable bit located in the sfr page control register (sfrpgcn). this function defaults to enabled upon reset. in this way,the autoswitching function will be enabled unless disabled in software. a summary of the sfr locations (address and sfr page) is provided in table 12.2. in the form of an sfr memory map. each memory location in the map has an sfr page row,denoting the page in which that sfr resides. note that certain sfrs are accessible from all sfr pages,and are denoted by the (all pages) designation. for exam- ple,the port i/o registers p0,p1,p2,and p3 all have the (all pages) designation,indicating these sfrs are accessible from all sfr pages regardless of the sfrpage register value. sfrnext sfrpage sfrlast cip-51 interrupt logic sfrpgcn bit figure 12.3. sfr page stack
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 127 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 12.2.6.3. sfr page stack example the following is an example that shows the operation of the sfr page stack during interrupts. in this example,the sfr page control is left in the default enabled state (i.e.,sfrpgen = 1),and the cip-51 is exe- cuting in-line code that is writing values to port 5 (sfr p5,located at address 0xd8 on sfr page 0x0f). the device is also using the programmable counter array (pca) and the 10-bit adc (adc2) window comparator to monitor a voltage. the pca is timing a critical control function in its interrupt service routine (isr),so its interrupt is enabled and is set to high priority. the adc2 is monitoring a voltage that is less important,but to minimize the soft- ware overhead its window comparator is being used with an associated isr that is set to low priority. at this point,the sfr page is set to access the port 5 sfr (sfrpage = 0x0f). see figure 12.4 below. 0x0f (port 5) sfrpage sfrlast sfrnext sfr page stack sfr's figure 12.4. sfr page stack while using sfr page 0x0f to access port 5
page 128 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n while cip-51 executes in-line code (writing values to port 5 in this example),adc2 window comparator interrupt occurs. the cip-51 vectors to the adc2 window comparator isr and pushes the current sfr page value (sfr page 0x0f) into sfrnext in the sfr page stack. the sfr page needed to access adc2s sfrs is then automatically placed in the sfrpage register (sfr page 0x02). sfrpage is considered the top of the sfr page stack. soft- ware can now access the adc2 sfrs. software may switch to any sfr page by writing a new value to the sfrpage register at any time during the adc2 isr to access sfrs that are not on sfr page 0x02. see figure 12.5 below. 0x02 (adc2) 0x0f (port 5) sfrpage sfrlast sfrnext sfrpage pushed to sfrnext sfr page 0x02 automatically pushed on stack in sfrpage on adc2 interrupt figure 12.5. sfr page stack after adc2 window comparator interrupt occurs
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 129 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information while in the adc2 isr,a pca interrupt occurs. recall the pca interrupt is configured as a high priority interrupt, while the adc2 interrupt is configured as a low priority interrupt. thus,the cip-51 will now vector to the high prior- ity pca isr. upon doing so,the cip-51 will automatically place the sfr page needed to access the pcas special function registers into the sfrpage register,sfr page 0x00. the value that was in the sfrpage register before the pca interrupt (sfr page 2 for adc2) is pushed down the stack into sfrnext. likewise,the value that was in the sfrnext register before the pca interrupt (in this case sfr page 0x0f for port 5) is pushed down to the sfr- last register,the bottom of the stack. note that a value stored in sfrlast (via a previous software write to the sfrlast register) will be overwritten. see figure 12.6 below. 0x00 (pca) 0x02 (adc2) 0x0f (port 5) sfrpage sfrlast sfrnext sfr page 0x00 automatically pushed on stack in sfrpage on pca interrupt sfrpage pushed to sfrnext sfrnext pushed to sfrlast figure 12.6. sfr page stack upon pca interrupt occurring during an adc2 isr
page 130 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n on exit from the pca interrupt service routine,the cip-51 will return to the adc2 window comparator isr. on execution of the reti instruction,sfr page 0x00 used to access the pca registers will be automatically popped off of the sfr page stack,and the contents of the sfrnext register will be moved to the sfrpage register. software in the adc2 isr can continue to access sfrs as it did prior to the pca interrupt. likewise,the contents of sfr- last are moved to the sfrnext register. recall this was the sfr page value 0x0f being used to access port 5 before the adc2 interrupt occurred. see figure 12.7 below. 0x02 (adc2) 0x0f (port 5) sfrpage sfrlast sfrnext sfr page 0x00 automatically popped off of the stack on return from interrupt sfrnext popped to sfrpage sfrlast popped to sfrnext figure 12.7. sfr page stack upon return from pca interrupt
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 131 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information on the execution of the reti instruction in the adc2 window comparator isr,the value in sfrpage register is overwritten with the contents of sfrnext. the cip-51 may now access the port 5 sfr bits as it did prior to the interrupts occurring. see figure 12.8 below. note that in the above example,all three bytes in the sfr page stack are accessible via the sfrpage,sfrnext, and sfrlast special function registers. if the stack is altered while servicing an interrupt,it is possible to return to a different sfr page upon interrupt exit than selected prior to the interrupt call. direct access to the sfr page stack can be useful to enable real-time operating systems to control and manage context switching between multiple tasks. push operations on the sfr page stack only occur on interrupt service,and pop operations only occur on interrupt exit (execution on the reti instruction). the automatic switching of the sfrpage and operation of the sfr page stack as described above can be disabled in software by clearing the sfr automatic page enable bit (sfrpgen) in the sfr page control register (sfrpgcn). see figure 12.9. 0x0f (port 5) sfrpage sfrlast sfrnext sfr page 0x02 automatically popped off of the stack on return from interrupt sfrnext popped to sfrpage figure 12.8. sfr page stack upon return from adc2 window interrupt
page 132 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 12.9. sfrpgcn: sfr page control register bits7-1: reserved. bit0: sfrpgen: sfr automatic page control enable. upon interrupt,the c8051 core will vector to the specified interrupt service routine and automati- cally switch the sfr page to the corresponding peripheral or functions sfr page. this bit is used to control this autopaging function. 0: sfr automatic paging disabled. c8051 core will not automatically change to the appropriate sfr page (i.e.,the sfr page that contains the sfrs for the peripheral/function that was the source of the interrupt). 1: sfr automatic paging enabled. upon interrupt,the c8051 will switch the sfr page to the page that contains the sfrs for the peripheral or function that is the source of the interrupt. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue - - - - - - - sfrpgen 00000001 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x96 f figure 12.10. sfrpage: sfr page register bits7-0: sfr page bits: byte represents the sfr page the c8051 mcu uses when reading or modifying sfrs. write: sets the sfr page. read: byte is the sfr page the c8051 mcu is using. when enabled in the sfr page control register (sfrpgen),the c8051 will automatically switch to the sfr page that contains the sfrs of the corresponding peripheral/function that caused the inter- rupt,and return to the previous sfr page upon return from interrupt (unless sfr stack was altered before a returning from the interrupt). sfrpage is the top byte of the sfr page stack,and push/pop events of this stack are caused by interrupts (and not by reading/writing to the sfrpage register) r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x84 all pages
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 133 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 12.11. sfrnext: sfr next register bits7-0: sfr page stack bits: sfr page context is retained upon interrupts/return from interrupts in a 3 byte sfr page stack: sfrpage is the first entry,sfrnext is the second,and sfrlast is the third entry. the sfr stack bytes may be used to alter the context in the sfr page stack,and will not cause the stack to push or pop. only interrupts and return from interrupt cause push and pop the sfr page stack. write: sets the sfr page contained in the second byte of the sfr stack. this will cause the sfrpage sfr to have this sfr page value upon a return from interrupt. read: returns the value of the sfr page contained in the second byte of the sfr stack. this is the value that will go to the sfr page register upon a return from interrupt. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x85 all pages figure 12.12. sfrlast: sfr last register bits7-0: sfr page stack bits: sfr page context is retained upon interrupts/return from interrupts in a 3 byte sfr page stack: sfrpage is the first entry,sfrnext is the second,and sfrlast is the third entry. the sfr stack bytes may be used to alter the context in the sfr page stack,and will not cause the stack to push or pop. only interrupts and return from interrupt cause push and pop the sfr page stack. write: sets the sfr page in the last entry of the sfr stack. this will cause the sfrnext sfr to have this sfr page value upon a return from interrupt. read: returns the value of the sfr page contained in the last entry of the sfr stack. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x86 all pages
page 134 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n table 12.2. special function register (sfr) memory map a d d r e s s sfr p a g e 0(8) 1(9) 2(a) 3(b) 4(c) 5(d) 6(e) 7(f) f8 0 1 2 3 f spi0cn can0cn dma0cf p7 pca0l dma0ctl pca0h dma0cth pca0cpl0 dma0csl pca0cph0 dma0csh pca0cpl1 dma0bnd pca0cph1 dma0isw wdtcn (all pages) f0 0 1 2 3 f b (all pages) eip1 (all pages) eip2 (all pages) e8 0 1 2 3 f adc0cn adc1cn adc2cn p6 pca0cpl2 pca0cph2 pca0cpl3 pca0cph3 pca0cpl4 pca0cph4 rstsrc e0 0 1 2 3 f acc (all pages) pca0cpl5 xbr0 pca0cph5 xbr1 xbr2 xbr3 eie1 (all pages) eie2 (all pages) d8 0 1 2 3 f pca0cn can0datl dma0cn p5 pca0md can0dath dma0dal pca0cpm0 can0adr dma0dah pca0cpm1 can0tst dma0dsl pca0cpm2 dma0dsh pca0cpm3 dma0ipt pca0cpm4 dma0idt pca0cpm5 d0 0 1 2 3 f psw (all pages) ref0cn ref1cn ref2cn dac0l dac1l dac0h dac1h dac0cn dac1cn c8 0 1 2 3 f tmr2cn tmr3cn tmr4cn p4 tmr2cf tmr3cf tmr4cf rcap2l rcap3l rcap4l rcap2h rcap3h rcap4h tmr2l tmr3l tmr4l tmr2h tmr3h tmr4h smb0cr c0 0 1 2 3 f smb0cn can0sta smb0sta smb0dat smb0adr adc0gtl adc2gtl adc0gth adc2gth adc0ltl adc2ltl adc0lth adc2lth b8 0 1 2 3 f ip (all pages) saden0 amx2cf adc0cpt amx0sl amx2sl adc0ccf adc0cf adc1cf adc2cf adc0l adc1l adc2l adc0h adc1h adc2h 0(8) 1(9) 2(a) 3(b) 4(c) 5(d) 6(e) 7(f)
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 135 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information b0 0 1 2 3 f p3 (all pages) flscl flacl a8 0 1 2 3 f ie (all pages) saddr0 p1mdin p2mdin a0 0 1 2 3 f p2 (all pages) emi0tc emi0cn emi0cf p0mdout p1mdout p2mdout p3mdout 98 0 1 2 3 f scon0 scon1 sbuf0 sbuf1 spi0cfg spi0dat p4mdout spi0ckr p5mdout p6mdout p7mdout 90 0 1 2 3 f p1 (all pages) ssta0 sfrpgcn clksel 88 0 1 2 3 f tcon cpt0cn cpt1cn cpt2cn tmod cpt0md cpt1md cpt2md tl0 oscicn tl1 oscicl th0 oscxcn th1 ckcon psctl 80 0 1 2 3 f p0 (all pages) sp (all pages) dpl (all pages) dph (all pages) sfrpage (all pages) sfrnext (all pages) sfrlast (all pages) pcon (all pages) table 12.3. special function registers sfrs are listed in alphabetical order. all undefined sfr locations are reserved. register address sfr page description page no. b 0xf0 all pages b register page 142 acc 0xe0 all pages accumulator page 142 adc0ccf 0xbb f adc0 calibration coefficient page 63 adc0cf 0xbc 0 adc0 configuration page 53 adc0cn 0xe8 0 adc0 control page 55 adc0cpt 0xba f adc0 calibration pointer page 63 adc0gth 0xc5 0 adc0 greater-than high page 64 adc0gtl 0xc4 0 adc0 greater-than low page 64 table 12.2. special function register (sfr) memory map 0(8) 1(9) 2(a) 3(b) 4(c) 5(d) 6(e) 7(f)
page 136 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n adc0h 0xbf 0 adc0 data word high page 58 adc0l 0xbe 0 adc0 data word low page 58 adc0lth 0xc7 0 adc0 less-than high page 65 adc0ltl 0xc6 0 adc0 less-than low page 65 adc1cf 0xbc 1 adc1 configuration page 54 adc1cn 0xe8 1 adc1 control page 56 adc1h 0xbf 1 adc1 data word high page 60 adc1l 0xbe 1 adc1 data word low page 60 adc2cf 0xbc 2 adc2 configuration page 90 adc2cn 0xe8 2 adc2 control page 92 adc2gth 0xc5 2 adc2 greater-than high page 93 adc2gtl 0xc4 2 adc2 greater-than low page 93 adc2h 0xbf 2 adc2 data word high page 91 adc2l 0xbe 2 adc2 data word low page 91 adc2lth 0xc7 2 adc2 less-than high page 94 adc2ltl 0xc6 2 adc2 less-than low page 94 amx0sl 0xbb 0 adc0 multiplexer channel select page 89 amx2cf 0xba 2 adc2 analog multiplexer configuration page 90 amx2sl 0xbb 2 adc2 analog multiplexer channel select page 89 can0adr 0xda 1 can0 address page 221 can0cn 0xf8 1 can0 control page 221 can0dath 0xd9 1 can0 data high page 220 can0datl 0xd8 1 can0 data low page 220 can0sta 0xc0 1 can0 status page 222 can0tst 0xdb 1 can0 test page 222 ckcon 0x8e 0 clock control page 277 clksel 0x97 f oscillator clock selection register page 163 cpt0cn 0x88 1 comparator 0 control page 114 cpt0md 0x89 1 comparator 0 configuration page 115 cpt1cn 0x88 2 comparator 1 control page 114 cpt1md 0x89 2 comparator 1 configuration page 115 cpt2cn 0x88 3 comparator 2 control page 114 cpt2md 0x89 3 comparator 2 configuration page 115 dac0cn 0xd4 0 dac0 control page 102 dac0h 0xd3 0 dac0 high page 101 dac0l 0xd2 0 dac0 low page 101 dac1cn 0xd4 1 dac1 control page 104 dac1h 0xd3 1 dac1 high page 103 dac1l 0xd2 1 dac1 low page 103 dma0bnd 0xfd 3 dma0 instruction boundary page 79 dma0cf 0xf8 3 dma0 configuration page 77 dma0cn 0xd8 3 dma0 control page 76 dma0csh 0xfc 3 dma0 repeat counter status high byte page 81 dma0csl 0xfb 3 dma0 repeat counter status low byte page 81 table 12.3. special function registers sfrs are listed in alphabetical order. all undefined sfr locations are reserved. register address sfr page description page no.
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 137 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information dma0cth 0xfa 3 dma0 repeat counter limit high byte page 81 dma0ctl 0xf9 3 dma0 repeat counter limit low byte page 81 dma0dah 0xda 3 dma0 data address beginning high byte page 80 dma0dal 0xd9 3 dma0 data address beginning low byte page 80 dma0dsh 0xdc 3 dma0 data address pointer high byte page 80 dma0dsl 0xdb 3 dma0 data address pointer low byte page 80 dma0idt 0xde 3 dma0 instruction write data page 78 dma0ipt 0xdd 3 dma0 instruction write address page 78 dma0isw 0xfe 3 dma0 instruction status page 79 dph 0x83 all pages data pointer high page 140 dpl 0x82 all pages data pointer low page 140 eie1 0xe6 all pages extended interrupt enable 1 page 148 eie2 0xe7 all pages extended interrupt enable 2 page 149 eip1 0xf6 all pages extended interrupt priority 1 page 150 eip2 0xf7 all pages extended interrupt priority 2 page 151 emi0cf 0xa3 0 emif configuration page 177? emi0cn 0xa2 0 emif control page 177? emi0tc 0xa1 0 emif timing control page 182? flacl 0xb7 f flash access limit page 171 flscl 0xb7 0 flash scale page 172 ie 0xa8 all pages interrupt enable page 146 ip 0xb8 all pages interrupt priority page 147 oscicl 0x8b f internal oscillator calibration page 162 oscicn 0x8a f internal oscillator control page 162 oscxcn 0x8c f external oscillator control page 164 p0 0x80 all pages port 0 latch page 202 p0mdout 0xa4 f port 0 output mode configuration page 202 p1 0x90 all pages port 1 latch page 203 p1mdin 0xad f port 1 input mode page 203 p1mdout 0xa5 f port 1 output mode configuration page 204 p2 0xa0 all pages port 2 latch page 204 p2mdin 0xae f port 2 input mode page 205 p2mdout 0xa6 f port 2 output mode configuration page 205 p3 0xb0 all pages port 3 latch page 206? p3mdout 0xa7 f port 3 output mode configuration page 206? p4 0xc8 f port 4 latch page 209? p4mdout 0x9c f port 4 output mode configuration page 209? p5 0xd8 f port 5 latch page 210? p5mdout 0x9d f port 5 output mode configuration page 210? p6 0xe8 f port 6 latch page 211? p6mdout 0x9e f port 6 output mode configuration page 211? p7 0xf8 f port 7 latch page 212? p7mdout 0x9f f port 7 output mode configuration page 212? pca0cn 0xd8 0 pca control page 296 table 12.3. special function registers sfrs are listed in alphabetical order. all undefined sfr locations are reserved. register address sfr page description page no.
page 138 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n pca0cph0 0xfc 0 pca capture 0 high page 300 pca0cph1 0xfe 0 pca capture 1 high page 300 pca0cph2 0xea 0 pca capture 2 high page 300 pca0cph3 0xec 0 pca capture 3 high page 300 pca0cph4 0xee 0 pca capture 4 high page 300 pca0cph5 0xe2 0 pca capture 5 high page 300 pca0cpl0 0xfb 0 pca capture 0 low page 300 pca0cpl1 0xfd 0 pca capture 1 low page 300 pca0cpl2 0xe9 0 pca capture 2 low page 300 pca0cpl3 0xeb 0 pca capture 3 low page 300 pca0cpl4 0xed 0 pca capture 4 low page 300 pca0cpl5 0xe1 0 pca capture 5 low page 300 pca0cpm0 0xda 0 pca module 0 mode register page 298 pca0cpm1 0xdb 0 pca module 1 mode register page 298 pca0cpm2 0xdc 0 pca module 2 mode register page 298 pca0cpm3 0xdd 0 pca module 3 mode register page 298 pca0cpm4 0xde 0 pca module 4 mode register page 298 pca0cpm5 0xdf 0 pca module 5 mode register page 298 pca0h 0xfa 0 pca counter high page 299 pca0l 0xf9 0 pca counter low page 299 pca0md 0xd9 0 pca mode page 297 pcon 0x87 all pages power control page 153 psctl 0x8f 0 program store r/w control page 173 psw 0xd0 all pages program status word page 141 rcap2h 0xcb 0 timer/counter 2 capture/reload high page 285 rcap2l 0xca 0 timer/counter 2 capture/reload low page 285 rcap3h 0xcb 1 timer/counter 3 capture/reload high page 285 rcap3l 0xca 1 timer/counter 3 capture/reload low page 285 rcap4h 0xcb 2 timer/counter 4 capture/reload high page 285 rcap4l 0xca 2 timer/counter 4 capture/reload low page 285 ref0cn 0xd1 0 voltage reference control 0 page 57 ref1cn 0xd1 1 voltage reference control 1 page 57 ref2cn 0xd1 2 voltage reference control 2 page 108?,page 110* rstsrc 0xef 0 reset source page 159 saddr0 0xa9 0 uart 0 slave address page 259 saden0 0xb9 0 uart 0 slave address enable page 259 sbuf0 0x99 0 uart 0 data buffer page 259 sbuf1 0x99 1 uart 1 data buffer page 267 scon0 0x98 0 uart 0 control page 257 scon1 0x98 1 uart 1 control page 266 sfrlast 0x86 all pages sfr page stack access register page 133 sfrnext 0x85 all pages sfr page register page 133 sfrpage 0x84 all pages sfr page register page 132 sfrpgcn 0x96 f sfr page control register page 132 table 12.3. special function registers sfrs are listed in alphabetical order. all undefined sfr locations are reserved. register address sfr page description page no.
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 139 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information smb0adr 0xc3 0 smbus slave address page 231 smb0cn 0xc0 0 smbus control page 229 smb0cr 0xcf 0 smbus clock rate page 230 smb0dat 0xc2 0 smbus data page 231 smb0sta 0xc1 0 smbus status page 232 sp 0x81 all pages stack pointer page 140 spi0cfg 0x9a 0 spi configuration page 241 spi0ckr 0x9d 0 spi clock rate control page 243 spi0cn 0xf8 0 spi control page 242 spi0dat 0x9b 0 spi data page 244 ssta0 0x91 0 uart 0 status page 258 tcon 0x88 0 timer/counter control page 275 th0 0x8c 0 timer/counter 0 high page 278 th1 0x8d 0 timer/counter 1 high page 278 tl0 0x8a 0 timer/counter 0 low page 278 tl1 0x8b 0 timer/counter 1 low page 278 tmod 0x89 0 timer/counter mode page 276 tmr2cf 0xc9 0 timer/counter 2 configuration page 284 tmr2cn 0xc8 0 timer/counter 2 control page 283 tmr2h 0xcd 0 timer/counter 2 high page 286 tmr2l 0xcc 0 timer/counter 2 low page 285 tmr3cf 0xc9 1 timer/counter 3 configuration page 284 tmr3cn 0xc8 1 timer/counter 3 control page 283 tmr3h 0xcd 1 timer/counter 3 high page 286 tmr3l 0xcc 1 timer/counter 3 low page 285 tmr4cf 0xc9 2 timer/counter 4 configuration page 284 tmr4cn 0xc8 2 timer/counter 4 control page 283 tmr4h 0xcd 2 timer/counter 4 high page 286 tmr4l 0xcc 2 timer/counter 4 low page 285 wdtcn 0xff all pages watchdog timer control page 158 xbr0 0xe1 f port i/o crossbar control 0 page 198 xbr1 0xe2 f port i/o crossbar control 1 page 199 xbr2 0xe3 f port i/o crossbar control 2 page 200 xbr3 0xe4 f port i/o crossbar control 3 page 201 ? refers to a register in the C8051F060/2 only. * refers to a register in the c8051f061/3 only. table 12.3. special function registers sfrs are listed in alphabetical order. all undefined sfr locations are reserved. register address sfr page description page no.
page 140 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 12.2.7. register descriptions following are descriptions of sfrs related to the operation of the cip-51 system controller. reserved bits should not be set to logic l. future product versions may use these bits to implement new features in which case the reset value of the bit will be logic 0,selecting the feature's default state. detailed descriptions of the remaining sfrs are included in the sections of the datasheet associated with their corresponding system function. figure 12.13. sp: stack pointer bits7-0: sp: stack pointer. the stack pointer holds the location of the top of the stack. the stack pointer is incremented before every push operation. the sp register defaults to 0x07 after reset. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x81 all pages f i gure 12 . 14 .dpl:datapo i nter low byte bits7-0: dpl: data pointer low. the dpl register is the low byte of the 16-bit dptr. dptr is used to access indirectly addressed xram and flash memory. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x82 all pages figure 12.15. dph: data pointer high byte bits7-0: dph: data pointer high. the dph register is the high byte of the 16-bit dptr. dptr is used to access indirectly addressed xram and flash memory. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x83 all pages
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 141 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 12.16. psw: program status word bit7: cy: carry flag. this bit is set when the last arithmetic operation resulted in a carry (addition) or a borrow (subtrac- tion). it is cleared to 0 by all other arithmetic operations. bit6: ac: auxiliary carry flag. this bit is set when the last arithmetic operation resulted in a carry into (addition) or a borrow from (subtraction) the high order nibble. it is cleared to 0 by all other arithmetic operations. bit5: f0: user flag 0. this is a bit-addressable,general purpose flag for use under software control. bits4-3: rs1-rs0: register bank select. these bits select which register bank is used during register accesses. bit2: ov: overflow flag. this bit is set to 1 if the last arithmetic operation resulted in a carry (addition),borrow (subtraction), or overflow (multiply or divide). it is cleared to 0 by all other arithmetic operations. bit1: f1: user flag 1. this is a bit-addressable,general purpose flag for use under software control. bit0: parity: parity flag. this bit is set to 1 if the sum of the eight bits in the accumulator is odd and cleared if the sum is even. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue cy ac f0 rs1 rs0 ov f1 parity 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xd0 all pages rs1 rs0 register bank address 0 0 0 0x00 - 0x07 0 1 1 0x08 - 0x0f 1 0 2 0x10 - 0x17 1 1 3 0x18 - 0x1f
page 142 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 12.17. acc: accumulator bits7-0: acc: accumulator. this register is the accumulator for arithmetic operations. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue acc.7 acc.6 acc.5 acc.4 acc.3 acc.2 acc.1 acc.0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xe0 all pages figure 12.18. b: b register bits7-0: b: b register. this register serves as a second accumulator for certain arithmetic operations. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue b.7 b.6 b.5 b.4 b.3 b.2 b.1 b.0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xf0 all pages
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 143 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 12.3. interrupt handler the cip-51 includes an extended interrupt system supporting a total of 22 interrupt sources with two priority levels. the allocation of interrupt sources between on-chip peripherals and external inputs pins varies according to the spe- cific version of the device. each interrupt source has one or more associated interrupt-pending flag(s) located in an sfr. when a peripheral or external source meets a valid interrupt condition,the associated interrupt-pending flag is set to logic 1. if interrupts are enabled for the source,an interrupt request is generated when the interrupt-pending flag is set. as soon as execution of the current instruction is complete,the cpu generates an lcall to a predetermined address to begin execution of an interrupt service routine (isr). each isr must end with an reti instruction,which returns pro- gram execution to the next instruction that would have been executed if the interrupt request had not occurred. if interrupts are not enabled,the interrupt-pending flag is ignored by the hardware and program execution continues as normal. (the interrupt-pending flag is set to logic 1 regardless of the interrupt's enable/disable state.) each interrupt source can be individually enabled or disabled through the use of an associated interrupt enable bit in an sfr (ie-eie2). however,interrupts must first be globally enabled by setting the ea bit (ie.7) to logic 1 before the individual interrupt enables are recognized. setting the ea bit to logic 0 disables all interrupt sources regardless of the individual interrupt-enable settings. some interrupt-pending flags are automatically cleared by the hardware when the cpu vectors to the isr. however, most are not cleared by the hardware and must be cleared by software before returning from the isr. if an interrupt- pending flag remains set after the cpu completes the return-from-interrupt (reti) instruction,a new interrupt request will be generated immediately and the cpu will re-enter the isr after the completion of the next instruction. 12.3.1. mcu interrupt sources and vectors the mcus support 22 interrupt sources. software can simulate an interrupt event by setting any interrupt-pending flag to logic 1. if interrupts are enabled for the flag,an interrupt request will be generated and the cpu will vector to the isr address associated with the interrupt-pending flag. mcu interrupt sources,associated vector addresses,prior- ity order and control bits are summarized in table 12.4. refer to the datasheet section associated with a particular on- chip peripheral for information regarding valid interrupt conditions for the peripheral and the behavior of its inter- rupt-pending flag(s). 12.3.2. external interrupts the external interrupt sources (/int0 and /int1) are configurable as active-low level-sensitive or active-low edge- sensitive inputs depending on the setting of bits it0 (tcon.0) and it1 (tcon.2). ie0 (tcon.1) and ie1 (tcon.3) serve as the interrupt-pending flag for the /int0 and /int1 external interrupts,respectively. if an /int0 or /int1 external interrupt is configured as edge-sensitive,the corresponding interrupt-pending flag is automatically cleared by the hardware when the cpu vectors to the isr. when configured as level sensitive,the interrupt-pending flag fol- lows the state of the external interrupt's input pin. the external interrupt source must hold the input active until the interrupt request is recognized. it must then deactivate the interrupt request before execution of the isr completes or another interrupt request will be generated.
page 144 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n table 12.4. interrupt summary interrupt source interrupt vector priority order pending flag bit addressable? cleared by hw? enable flag priority control reset 0x0000 top none n/a n/a always enabled always highest external interrupt 0 (/int0) 0x0003 0 ie0 (tcon.1) y y ex0 (ie.0) px0 (ip.0) timer 0 overflow 0x000b 1 tf0 (tcon.5) y y et0 (ie.1) pt0 (ip.1) external interrupt 1 (/int1) 0x0013 2 ie1 (tcon.3) y y ex1 (ie.2) px1 (ip.2) timer 1 overflow 0x001b 3 tf1 (tcon.7) y y et1 (ie.3) pt1 (ip.3) uart0 0x0023 4 ri0 (scon0.0) ti0 (scon0.1) y es0 (ie.4) ps0 (ip.4) timer 2 0x002b 5 tf2 (tmr2cn.7) y et2 (ie.5) pt2 (ip.5) serial peripheral interface 0x0033 6 spif (spi0cn.7) y espi0 (eie1.0) pspi0 (eip1.0) smbus interface 0x003b 7 si (smb0cn.3) y esmb0 (eie1.1) psmb0 (eip1.1) adc0 window comparator 0x0043 8 ad0wint (adc0cn.1) y ewadc0 (eie1.2) pwadc0 (eip1.2) programmable counter array 0x004b 9 cf (pca0cn.7) ccfn (pca0cn.n) y epca0 (eie1.3) ppca0 (eip1.3) comparator 0 0x0053 10 cp0fif/cp0rif (cpt0cn.4/.5) y cp0ie (eie1.4) pcp0 (eip1.4) comparator 1 0x005b 11 cp1fif/cp1rif (cpt1cn.4/.5) y cp1ie (eie1.5) pcp1 (eip1.5) comparator 2 0x0063 12 cp2fif/cp2rif (cpt2cn.4/.5) y cp2ie (eie1.6) pcp2 (eip1.6) adc0 end of conversion 0x006b 13 adc0int (adc0cn.5) y eadc0 (eie1.7) padc0 (eip1.7) timer 3 0x0073 14 tf3 (tmr3cn.7) y et3 (eie2.0) pt3 (eip2.0) adc1 end of conversion 0x007b 15 adc1int (adc1cn.5) y eadc1 (eie2.1) padc1 (eip2.1) timer 4 0x0083 16 tf4 (tmr4cn.7) y et4 (eie2.2) pt4 (eip2.2) adc2 window comparator 0x008b 17 ad2wint (adc2cn.1) y ewadc2 (eie2.3) pwadc2 (eip2.3) adc2 end of conversion 0x0093 18 ad2int (adc2cn.5) y eadc2 (eie2.4) padc2 (eip2.4) can interrupt 0x009b 19 can0cn.7 y y ecan0 (eie2.5) pcan0 (eip2.5) uart1 0x00a3 20 ri1 (scon1.0) ti1 (scon1.1) y es1 (eip2.6) ps1 (eip2.6) dma0 interrupt 0x00ab 21 dma0int (dma0cn.6) y edma0 (eie2.7) pdma0 (eip2.7)
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 145 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 12.3.3. interrupt priorities each interrupt source can be individually programmed to one of two priority levels: low or high. a low priority inter- rupt service routine can be preempted by a high priority interrupt. a high priority interrupt cannot be preempted. each interrupt has an associated interrupt priority bit in an sfr (ip-eip2) used to configure its priority level. low priority is the default. if two interrupts are recognized simultaneously,the interrupt with the higher priority is serviced first. if both interrupts have the same priority level,a fixed priority order is used to arbitrate,given in table 12.4. 12.3.4. interrupt latency interrupt response time depends on the state of the cpu when the interrupt occurs. pending interrupts are sampled and priority decoded each system clock cycle. therefore,the fastest possible response time is 5 system clock cycles: 1 clock cycle to detect the interrupt and 4 clock cycles to complete the lcall to the isr. if an interrupt is pending when a reti is executed,a single instruction is executed before an lcall is made to service the pending interrupt. therefore,the maximum response time for an interrupt (when no other interrupt is currently being serviced or the new interrupt is of greater priority) occurs when the cpu is performing an reti instruction followed by a div as the next instruction. in this case,the response time is 18 system clock cycles: 1 clock cycle to detect the interrupt,5 clock cycles to execute the reti,8 clock cycles to complete the div instruction and 4 clock cycles to execute the lcall to the isr. if the cpu is executing an isr for an interrupt with equal or higher priority,the new interrupt will not be serviced until the current isr completes,including the reti and following instruction.
page 146 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 12.3.5. interrupt register descriptions the sfrs used to enable the interrupt sources and set their priority level are described below. refer to the datasheet section associated with a particular on-chip peripheral for information regarding valid interrupt conditions for the peripheral and the behavior of its interrupt-pending flag(s). figure 12.19. ie: interrupt enable bit7: ea: enable all interrupts. this bit globally enables/disables all interrupts. it overrides the individual interrupt mask settings. 0: disable all interrupt sources. 1: enable each interrupt according to its individual mask setting. bit6: iegf0: general purpose flag 0. this is a general purpose flag for use under software control. bit5: et2: enabler timer 2 interrupt. this bit sets the masking of the timer 2 interrupt. 0: disable timer 2 interrupt. 1: enable interrupt requests generated by the tf2 flag. bit4: es0: enable uart0 interrupt. this bit sets the masking of the uart0 interrupt. 0: disable uart0 interrupt. 1: enable uart0 interrupt. bit3: et1: enable timer 1 interrupt. this bit sets the masking of the timer 1 interrupt. 0: disable all timer 1 interrupt. 1: enable interrupt requests generated by the tf1 flag. bit2: ex1: enable external interrupt 1. this bit sets the masking of external interrupt 1. 0: disable external interrupt 1. 1: enable interrupt requests generated by the /int1 pin. bit1: et0: enable timer 0 interrupt. this bit sets the masking of the timer 0 interrupt. 0: disable all timer 0 interrupt. 1: enable interrupt requests generated by the tf0 flag. bit0: ex0: enable external interrupt 0. this bit sets the masking of external interrupt 0. 0: disable external interrupt 0. 1: enable interrupt requests generated by the /int0 pin. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue ea iegf0 et2 es0 et1 ex1 et0 ex0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xa8 all pages
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 147 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 12.20. ip: interrupt priority bits7-6: unused. read = 11b,write = don't care. bit5: pt2: timer 2 interrupt priority control. this bit sets the priority of the timer 2 interrupt. 0: timer 2 interrupt priority determined by default priority order. 1: timer 2 interrupts set to high priority level. bit4: ps0: uart0 interrupt priority control. this bit sets the priority of the uart0 interrupt. 0: uart0 interrupt priority determined by default priority order. 1: uart0 interrupts set to high priority level. bit3: pt1: timer 1 interrupt priority control. this bit sets the priority of the timer 1 interrupt. 0: timer 1 interrupt priority determined by default priority order. 1: timer 1 interrupts set to high priority level. bit2: px1: external interrupt 1 priority control. this bit sets the priority of the external interrupt 1 interrupt. 0: external interrupt 1 priority determined by default priority order. 1: external interrupt 1 set to high priority level. bit1: pt0: timer 0 interrupt priority control. this bit sets the priority of the timer 0 interrupt. 0: timer 0 interrupt priority determined by default priority order. 1: timer 0 interrupt set to high priority level. bit0: px0: external interrupt 0 priority control. this bit sets the priority of the external interrupt 0 interrupt. 0: external interrupt 0 priority determined by default priority order. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue - - pt2 ps0 pt1 px1 pt0 px0 11000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xb8 all pages
page 148 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 12.21. eie1: extended interrupt enable 1 bit7: eadc0: enable adc0 end of conversion interrupt. this bit sets the masking of the adc0 end of conversion interrupt. 0: disable adc0 conversion interrupt. 1: enable interrupt requests generated by the adc1 conversion interrupt. bit6: cp2ie: enable comparator (cp2) interrupt. this bit sets the masking of the cp2 interrupt. 0: disable cp2 interrupts. 1: enable interrupt requests generated by the cp2if flag. bit6: cp1ie: enable comparator (cp1) interrupt. this bit sets the masking of the cp1 interrupt. 0: disable cp1 interrupts. 1: enable interrupt requests generated by the cp1if flag. bit6: cp0ie: enable comparator (cp0) interrupt. this bit sets the masking of the cp0 interrupt. 0: disable cp0 interrupts. 1: enable interrupt requests generated by the cp0if flag. bit3: epca0: enable programmable counter array (pca0) interrupt. this bit sets the masking of the pca0 interrupts. 0: disable all pca0 interrupts. 1: enable interrupt requests generated by pca0. bit2: ewadc0: enable window comparison adc0 interrupt. this bit sets the masking of adc0 window comparison interrupt. 0: disable adc0 window comparison interrupt. 1: enable interrupt requests generated by adc0 window comparisons. bit1: esmb0: enable system management bus (smbus0) interrupt. this bit sets the masking of the smbus interrupt. 0: disable all smbus interrupts. 1: enable interrupt requests generated by the si flag. bit0: espi0: enable serial peripheral interface (spi0) interrupt. this bit sets the masking of spi0 interrupt. 0: disable all spi0 interrupts. 1: enable interrupt requests generated by the spi0 flag. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue eadc0 cp2ie cp1ie cp0ie epca0 ewadc0 esmb0 espi0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xe6 all pages
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 149 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 12.22. eie2: extended interrupt enable 2 bit7: edma0: enable dma0 interrupt. this bit sets the masking of the dma0 interrupt. 0: disable dma0 interrupt. 1: enable dma0 interrupt. bit6: es1: enable uart1 interrupt. this bit sets the masking of the uart1 interrupt. 0: disable uart1 interrupt. 1: enable uart1 interrupt. bit5: ecan0: enable can controller interrupt. this bit sets the masking of the can controller interrupt. 0: disable can controller interrupt. 1: enable interrupt requests generated by the can controller. bit4: eadc2: enable adc2 end of conversion interrupt. this bit sets the masking of the adc2 end of conversion interrupt. 0: disable adc2 end of conversion interrupt. 1: enable interrupt requests generated by the adc2 end of conversion interrupt. bit3: ewadc2: enable window comparison adc1 interrupt. this bit sets the masking of adc2 window comparison interrupt. 0: disable adc2 window comparison interrupt. 1: enable interrupt requests generated by adc2 window comparisons. bit2: et4: enable timer 4 interrupt this bit sets the masking of the timer 4 interrupt. 0: disable timer 4 interrupt. 1: enable interrupt requests generated by the tf4 flag. bit1: eadc1: enable adc1 end of conversion interrupt. this bit sets the masking of the adc1 end of conversion interrupt. 0: disable adc1 conversion interrupt. 1: enable interrupt requests generated by the adc1 conversion interrupt. bit0: et3: enable timer 3 interrupt. this bit sets the masking of the timer 3 interrupt. 0: disable all timer 3 interrupts. 1: enable interrupt requests generated by the tf3 flag. r/w r/w r/w r/w r/w r/w r/w r/w reset value edma0 es1 ecan0 eadc2 ewadc2 et4 eadc1 et3 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xe7 all pages
page 150 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 12.23. eip1: extended interrupt priority 1 bit7: padc0: adc end of conversion interrupt priority control. this bit sets the priority of the adc0 end of conversion interrupt. 0: adc0 end of conversion interrupt set to low priority level. 1: adc0 end of conversion interrupt set to high priority level. bit6: pcp2: comparator2 (cp2) interrupt priority control. this bit sets the priority of the cp2 interrupt. 0: cp2 interrupt set to low priority level. 1: cp2 interrupt set to high priority level. bit5: pcp1: comparator1 (cp1) interrupt priority control. this bit sets the priority of the cp1 interrupt. 0: cp1 interrupt set to low priority level. 1: cp1 interrupt set to high priority level. bit4: pcp0: comparator0 (cp0) interrupt priority control. this bit sets the priority of the cp0 interrupt. 0: cp0 interrupt set to low priority level. 1: cp0 interrupt set to high priority level. bit3: ppca0: programmable counter array (pca0) interrupt priority control. this bit sets the priority of the pca0 interrupt. 0: pca0 interrupt set to low priority level. 1: pca0 interrupt set to high priority level. bit2: pwadc0: adc0 window comparator interrupt priority control. this bit sets the priority of the adc0 window interrupt. 0: adc0 window interrupt set to low priority level. 1: adc0 window interrupt set to high priority level. bit1: psmb0: system management bus (smbus0) interrupt priority control. this bit sets the priority of the smbus0 interrupt. 0: smbus interrupt set to low priority level. 1: smbus interrupt set to high priority level. bit0: pspi0: serial peripheral interface (spi0) interrupt priority control. this bit sets the priority of the spi0 interrupt. 0: spi0 interrupt set to low priority level. 1: spi0 interrupt set to high priority level. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue padc0 pcp2 pcp1 pcp0 ppca0 pwadc0 psmb0 pspi0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xf6 all pages
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 151 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 12.24. eip2: extended interrupt priority 2 bit7: pdma0: dma0 interrupt priority control. this bit sets the priority of the dma0 interrupt. 0: dma0 interrupt set to low priority. 1: dma0 interrupt set to high priority. bit6: ps1: uart1 interrupt priority control. this bit sets the priority of the uart1 interrupt. 0: uart1 interrupt set to low priority. 1: uart1 interrupt set to high priority. bit5: pcan0: can interrupt priority control. this bit sets the priority of the can interrupt. 0: can interrupt set to low priority level. 1: can interrupt set to high priority level. bit4: padc2: adc2 end of conversion interrupt priority control. this bit sets the priority of the adc2 end of conversion interrupt. 0: adc2 end of conversion interrupt set to low priority. 1: adc2 end of conversion interrupt set to low priority. bit3: pwadc2: adc2 window comparator interrupt priority control. 0: adc2 window interrupt set to low priority. 1: adc2 window interrupt set to high priority. bit2: pt4: timer 4 interrupt priority control. this bit sets the priority of the timer 4 interrupt. 0: timer 4 interrupt set to low priority. 1: timer 4 interrupt set to low priority. bit1: padc1: adc end of conversion interrupt priority control. this bit sets the priority of the adc1 end of conversion interrupt. 0: adc1 end of conversion interrupt set to low priority level. 1: adc1 end of conversion interrupt set to high priority level. bit0: pt3: timer 3 interrupt priority control. this bit sets the priority of the timer 3 interrupts. 0: timer 3 interrupt priority determined by default priority order. 1: timer 3 interrupt set to high priority level. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue pdma0 ps1 pcan0 padc2 pwadc2 pt4 padc1 pt3 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xf7 all pages
page 152 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 12.4. power management modes the cip-51 core has two software programmable power management modes: idle and stop. idle mode halts the cpu while leaving the external peripherals and internal clocks active. in stop mode,the cpu is halted,all interrupts and timers (except the missing clock detector) are inactive,and the internal oscillator is stopped. since clocks are run- ning in idle mode,power consumption is dependent upon the system clock frequency and the number of peripherals left in active mode before entering idle. stop mode consumes the least power. figure 12.25 describes the power con- trol register (pcon) used to control the cip-51's power management modes. although the cip-51 has idle and stop modes built in (as with any standard 8051 architecture),power management of the entire mcu is better accomplished by enabling/disabling individual peripherals as needed. each analog periph- eral can be disabled when not in use and put into low power mode. digital peripherals,such as timers or serial buses, draw little power whenever they are not in use. turning off the oscillator saves even more power,but requires a reset to restart the mcu. 12.4.1. idle mode setting the idle mode select bit (pcon.0) causes the cip-51 to halt the cpu and enter idle mode as soon as the instruction that sets the bit completes. all internal registers and memory maintain their original data. all analog and digital peripherals can remain active during idle mode. idle mode is terminated when an enabled interrupt or /rst is asserted. the assertion of an enabled interrupt will cause the idle mode selection bit (pcon.0) to be cleared and the cpu to resume operation. the pending interrupt will be serviced and the next instruction to be executed after the return from interrupt (reti) will be the instruction immediately following the one that set the idle mode select bit. if idle mode is terminated by an internal or external reset,the cip-51 performs a normal reset sequence and begins program execution at address 0x0000. if enabled,the wdt will eventually cause an internal watchdog reset and thereby terminate the idle mode. this fea- ture protects the system from an unintended permanent shutdown in the event of an inadvertent write to the pcon register. if this behavior is not desired,the wdt may be disabled by software prior to entering the idle mode if the wdt was initially configured to allow this operation. this provides the opportunity for additional power savings, allowing the system to remain in the idle mode indefinitely,waiting for an external stimulus to wake up the system. refer to section 13.7 for more information on the use and configuration of the wdt. 12.4.2. stop mode setting the stop mode select bit (pcon.1) causes the cip-51 to enter stop mode as soon as the instruction that sets the bit completes. in stop mode,the cpu and internal oscillators are stopped,effectively shutting down all digital peripherals. each analog peripheral must be shut down individually prior to entering stop mode. stop mode can only be terminated by an internal or external reset. on reset,the cip-51 performs the normal reset sequence and begins program execution at address 0x0000. if enabled,the missing clock detector will cause an internal reset and thereby terminate the stop mode. the missing clock detector should be disabled if the cpu is to be put to sleep for longer than the mcd timeout of 100 s.
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 153 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 12.25. pcon: power control bits7-2: reserved. bit1: stop: stop mode select. writing a 1 to this bit will place the cip-51 into stop mode. this bit will always read 0. 1: cip-51 forced into power-down mode. (turns off internal oscillator). bit0: idle: idle mode select. writing a 1 to this bit will place the cip-51 into idle mode. this bit will always read 0. 1: cip-51 forced into idle mode. (shuts off clock to cpu,but clock to timers,interrupts,and all peripherals remain active.) r/wr/wr/wr/wr/wr/wr/wr/wresetvalue - - - - - - stop idle 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x87 all pages
page 154 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n notes
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 155 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 13. reset sources reset circuitry allows the controller to be easily placed in a predefined default condition. on entry to this reset state, the following occur: ? cip-51 halts program execution ? special function registers (sfrs) are initialized to their defined reset values ? external port pins are forced to a known configuration ? interrupts and timers are disabled. all sfrs are reset to the predefined values noted in the sfr detailed descriptions. the contents of internal data mem- ory are unaffected during a reset; any previously stored data is preserved. however,since the stack pointer sfr is reset,the stack is effectively lost even though the data on the stack are not altered. the i/o port latches are reset to 0xff (all logic 1s),activating internal weak pull-ups which take the external i/o pins to a high state. the external i/o pins do not go high immediately,but will go high within four system clock cycles after entering the reset state. this allows power to be conserved while the part is held in reset. for vdd monitor resets,the /rst pin is driven low until the end of the vdd reset timeout. on exit from the reset state,the program counter (pc) is reset,and the system clock defaults to the internal oscillator running at its lowest frequency. refer to section 14. oscillators onpage 161 for information on selecting and configuring the system clock source. the watchdog timer is enabled using its longest timeout interval (see sec- tion 13.7. watchdog timer reset onpage 157 ). once the system clock source is stable,program execution begins at location 0x0000. there are seven sources for putting the mcu into the reset state: power-on,power-fail,external /rst pin,external cnvstr2 signal,software command,comparator0,missing clock detector,and watchdog timer. each reset source is described in the following sections. wdt xtal1 xtal2 osc internal clock generator system clock cip-51 microcontroller core missing clock detector (one- shot) wdt strobe software reset extended interrupt handler clock select /rst + - vdd supply reset timeout (wired-or) system reset supply monitor pre reset funnel + - cp0+ comparator0 cp0- (port i/o) crossbar cnvstr2 (cnvstr reset enable) (cp0 reset enable) en wdt enable en mcd enable (wired-or) vdd monitor reset enable figure 13.1. reset sources
page 156 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 13.1. power-on reset the C8051F060/1/2/3 family incorporates a power supply monitor that holds the mcu in the reset state until vdd rises above the v rst level during power-up. see figure 13.2 for timing diagram,and refer to table 13.1 for the elec- trical characteristics of the power supply monitor circuit. the /rst pin is asserted low until the end of the 100 ms vdd monitor timeout in order to allow the vdd supply to stabilize. the vdd monitor reset is enabled and disabled using the external vdd monitor enable pin (monen). on exit from a power-on reset,the porsf flag (rstsrc.1) is set by hardware to logic 1. all of the other reset flags in the rstsrc register are indeterminate. porsf is cleared by all other resets. since all resets cause program exe- cution to begin at the same location (0x0000) software can read the porsf flag to determine if a power-up was the cause of reset. the contents of internal data memory should be assumed to be undefined after a power-on reset. 13.2. power-fail reset when a power-down transition or power irregularity causes vdd to drop below v rst ,the power supply monitor will drive the /rst pin low and return the cip-51 to the reset state. when vdd returns to a level above vrst,the cip-51 will leave the reset state in the same manner as that for the power-on reset (see figure 13.2). note that even though internal data memory contents are not altered by the power-fail reset,it is impossible to determine if vdd dropped below the level required for data retention. if the porsf flag is set to logic 1,the data may no longer be valid. 13.3. external reset the external /rst pin provides a means for external circuitry to force the mcu into a reset state. asserting the /rst pin low will cause the mcu to enter the reset state. it may be desirable to provide an external pull-up and/or decou- pling of the /rst pin to avoid erroneous noise-induced resets. the mcu will remain in reset until at least 12 clock cycles after the active-low /rst signal is removed. the pinrsf flag (rstsrc.0) is set on exit from an external reset. vdd monitor reset power-on reset /rst t volts 1.0 2.0 logic high logic low 100ms 100ms v d d 2.70 2.55 v rst figure 13.2. reset timing
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 157 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 13.4. missing clock detector reset the missing clock detector is essentially a one-shot circuit that is triggered by the mcu system clock. if the system clock goes away for more than 100 s,the one-shot will time out and generate a reset. after a missing clock detector reset,the mcdrsf flag (rstsrc.2) will be set,signifying the msd as the reset source; otherwise,this bit reads 0. the state of the /rst pin is unaffected by this reset. setting the mcdrsf bit,rstsrc.2 (see section 14. oscillators onpage 161 ) enables the missing clock detector. 13.5. comparator0 reset comparator0 can be configured as a reset input by writing a 1 to the c0rsef flag (rstsrc.5). comparator0 should be enabled using cpt0cn.7 (see section 11. comparators onpage 111 ) prior to writing to c0rsef to prevent any turn-on chatter on the output from generating an unwanted reset. the comparator0 reset is active-low: if the non-inverting input voltage (cp0+ pin) is less than the inverting input voltage (cp0- pin),the mcu is put into the reset state. after a comparator0 reset,the c0rsef flag (rstsrc.5) will read 1 signifying comparator0 as the reset source; otherwise,this bit reads 0. the state of the /rst pin is unaffected by this reset. 13.6. external cnvstr2 pin reset the external cnvstr2 signal can be configured as a reset input by writing a 1 to the cnvrsef flag (rstsrc.6). the cnvstr2 signal can appear on any of the p0,p1,p2 or p3 i/o pins as described in section 17.1. ports 0 through 3 and the priority crossbar decoder onpage 193 . note that the crossbar must be configured for the cnvstr2 signal to be routed to the appropriate port i/o. the crossbar should be configured and enabled before the cnvrsef is set. cnvstr2 cannot be used to start adc2 conversions when it is configured as a reset source. when configured as a reset,cnvstr2 is active-low and level sensitive. after a cnvstr2 reset,the cnvrsef flag (rstsrc.6) will read 1 signifying cnvstr2 as the reset source; otherwise,this bit reads 0. the state of the / rst pin is unaffected by this reset. 13.7. watchdog timer reset the mcu includes a programmable watchdog timer (wdt) running off the system clock. a wdt overflow will force the mcu into the reset state. to prevent the reset,the wdt must be restarted by application software before overflow. if the system experiences a software or hardware malfunction preventing the software from restarting the wdt,the wdt will overflow and cause a reset. this should prevent the system from running out of control. following a reset the wdt is automatically enabled and running with the default maximum time interval. if desired the wdt can be disabled by system software or locked on to prevent accidental disabling. once locked,the wdt cannot be disabled until the next system reset. the state of the /rst pin is unaffected by this reset. the wdt consists of a 21-bit timer running from the programmed system clock. the timer measures the period between specific writes to its control register. if this period exceeds the programmed limit,a wdt reset is generated. the wdt can be enabled and disabled as needed in software,or can be permanently enabled if desired. watchdog features are controlled via the watchdog timer control register (wdtcn) shown in figure 13.3. 13.7.1. enable/reset wdt the watchdog timer is both enabled and reset by writing 0xa5 to the wdtcn register. the user's application soft- ware should include periodic writes of 0xa5 to wdtcn as needed to prevent a watchdog timer overflow. the wdt is enabled and reset as a result of any system reset.
page 158 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 13.7.2. disable wdt writing 0xde followed by 0xad to the wdtcn register disables the wdt. the following code segment illustrates disabling the wdt: clr ea ; disable all interrupts mov wdtcn,#0deh ; disable software watchdog timer mov wdtcn,#0adh setb ea ; re-enable interrupts the writes of 0xde and 0xad must occur within 4 clock cycles of each other,or the disable operation is ignored. interrupts should be disabled during this procedure to avoid delay between the two writes. 13.7.3. disable wdt lockout writing 0xff to wdtcn locks out the disable feature. once locked out,the disable operation is ignored until the next system reset. writing 0xff does not enable or reset the watchdog timer. applications always intending to use the watchdog should write 0xff to wdtcn in the initialization code. 13.7.4. setting wdt interval wdtcn.[2:0] control the watchdog timeout interval. the interval is given by the following equation: ;where t sysclk is the system clock period. for a 3 mhz system clock,this provides an interval range of 0.021 ms to 349.5 ms. wdtcn.7 must be logic 0 when setting this interval. reading wdtcn returns the programmed interval. wdtcn.[2:0] reads 111b after a system reset. 4 3 wdtcn 20 C [] + t sysclk bits7-0: wdt control. writing 0xa5 both enables and reloads the wdt. writing 0xde followed within 4 system clocks by 0xad disables the wdt. writing 0xff locks out the disable feature. bit4: watchdog status bit (when read). reading the wdtcn.[4] bit indicates the watchdog timer status. 0: wdt is inactive. 1: wdt is active. bits2-0: watchdog timeout interval bits. the wdtcn.[2:0] bits set the watchdog timeout interval. when writing these bits,wdtcn.7 must be set to 0. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue xxxxx111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xff all pages figure 13.3. wdtcn: watchdog timer control register
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 159 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 13.4. rstsrc: reset source register bit7: reserved. bit6: cnvrsef: convert start reset source enable and flag write: 0: cnvstr2 is not a reset source. 1: cnvstr2 is a reset source (active low). read: 0:sourceofpriorresetwasnotcnvstr2. 1: source of prior reset was cnvstr2. bit5: c0rsef: comparator0 reset enable and flag. write: 0: comparator0 is not a reset source. 1: comparator0 is a reset source (active low). read: 0: source of last reset was not comparator0. 1: source of last reset was comparator0. bit4: swrsf: software reset force and flag. write: 0: no effect. 1: forces an internal reset. /rst pin is not effected. read: 0: source of last reset was not a write to the swrsf bit. 1: source of last reset was a write to the swrsf bit. bit3: wdtrsf: watchdog timer reset flag. 0: source of last reset was not wdt timeout. 1: source of last reset was wdt timeout. bit2: mcdrsf: missing clock detector flag. write: 0: missing clock detector disabled. 1: missing clock detector enabled; triggers a reset if a missing clock condition is detected. read: 0: source of last reset was not a missing clock detector timeout. 1: source of last reset was a missing clock detector timeout. bit1: porsf: power-on reset flag. this bit is set anytime a power-on reset occurs. this may be due to a true power-on reset or a vdd monitor reset. in either case,data memory should be considered indeterminate following the reset. the vdd monitor reset is enabled/disabled using the external vdd monitor enable pin. 0: source of last reset was not a power-on or vdd monitor reset. 1: source of last reset was a power-on or vdd monitor reset. note: when this flag is set, all other reset flags indeterminate. bit0: pinrsf: hw pin reset flag. write: 0: no effect. 1: forces a power-on reset. /rst is driven low. read: 0:sourceofpriorresetwasnot/rstpin. 1: source of prior reset was /rst pin. rr/wr/wr/wrr/wrr/wresetvalue - cnvrsef c0rsef swrsef wdtrsf mcdrsf porsf pinrsf 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xef 0
page 160 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n table 13.1. reset electrical characteristics -40c to +85c unless otherwise specified. parameter conditions min typ max units /rst output low voltage i ol = 8.5 ma,vdd = 2.7 v to 3.6 v 0.6 v /rst input high voltage 0.7 x vdd v /rst input low voltage 0.3 x vdd /rst input leakage current /rst = 0.0 v 50 a vdd for /rst output valid 1.0 v av+ for /rst output valid 1.0 v vdd por threshold (v rst ) 2.40 2.55 2.70 v minimum /rst low time to generate a system reset 10 ns reset time delay /rst rising edge after vdd crosses v rst threshold 80 100 120 ms missing clock detector timeout time from last system clock to reset initiation 100 220 500 s
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 161 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 14. oscillators C8051F060/1/2/3 devices include a programmable internal oscillator and an external oscillator drive circuit. the internal oscillator can be enabled,disabled and calibrated using the oscicn and oscicl registers,as shown in figure 14.1. the system clock can be sourced by the external oscillator circuit,the internal oscillator,or a scaled ver- sion of the internal oscillator. the internal oscillator's electrical specifications are given in table 14.1. 14.1. programmable internal oscillator all C8051F060/1/2/3 devices include a programmable internal oscillator that defaults as the system clock after a sys- tem reset. the internal oscillator period can be adjusted via the oscicl register as defined by figure 14.2,where f base is the frequency of the internal oscillator following a reset, ? t is the change in internal oscillator period,and ? oscicl is a change to the value held in register oscicl. oscicl is factory calibrated to obtain a 24.5 mhz base frequency ( f base ). electrical specifications for the precision internal oscillator are given in table 14.1. the programmed internal oscilla- tor frequency must not exceed 25 mhz. note that the system clock may be derived from the programmed internal oscillator divided by 1,2,4,or 8,as defined by the ifcn bits in register oscicn. figure 14.1. oscillator diagram osc programmable internal clock generator input circuit en sysclk n oscicl oscicn ioscen ifrdy ifcn1 ifcn0 xtal1 xtal2 option 2 vdd xtal1 option 1 option 4 xtal1 oscxcn xtlvld xoscmd2 xoscmd1 xoscmd0 xfcn2 xfcn1 xfcn0 clksel clksl 0 1 option 3 xtal1 xtal2
page 162 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n . figure 14.2. oscicl: internal oscillator calibration register bits 7-0: oscicl: internal oscillator calibration register this register calibrates the internal oscillator period. the reset value for oscicl defines the internal oscillator base frequency. the reset value is factory calibrated to generate an internal oscillator fre- quency of 24.5 mhz. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue va ri a b l e bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x8b f figure 14.3. oscicn: internal oscillator control register bit7: ioscen: internal oscillator enable bit 0: internal oscillator disabled 1: internal oscillator enabled bit6: ifrdy: internal oscillator frequency ready flag 0: internal oscillator not running at programmed frequency. 1: internal oscillator running at programmed frequency. bits5-2: reserved. bits1-0: ifcn1-0: internal oscillator frequency control bits 00: sysclk derived from internal oscillator divided by 8. 01: sysclk derived from internal oscillator divided by 4. 10: sysclk derived from internal oscillator divided by 2. 11: sysclk derived from internal oscillator divided by 1. r/w r r/w r r/w r/w r/w r/w reset value ioscen ifrdy - - - - ifcn1 ifcn0 11000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x8a f
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 163 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 14.2. external oscillator drive circuit the external oscillator circuit may drive an external crystal,ceramic resonator,capacitor,or rc network. a cmos clock may also provide a clock input. for a crystal or ceramic resonator configuration,the crystal/resonator must be wired across the xtal1 and xtal2 pins as shown in option 1 of figure 14.1. in rc,capacitor,or cmos clock configuration,the clock source should be wired to the xtal2 and/or xtal1 pin(s) as shown in option 2,3,or 4 of figure 14.1. the type of external oscillator must be selected in the oscxcn register,and the frequency control bits (xfcn) must be selected appropriately (see figure 14.5). 14.3. system clock selection the clksl bit in register clksel selects which oscillator generates the system clock. clksl must be set to 1 for the system clock to run from the external oscillator; however the external oscillator may still clock peripherals (timers,pca) when the internal oscillator is selected as the system clock. the system clock may be switched on-the- fly between the internal and external oscillator,so long as the selected oscillator is enabled and settled. the internal oscillator requires little start-up time,and may be enabled and selected as the system clock in the same write to oscicn. external crystals and ceramic resonators typically require a start-up time before they are settled and ready for use as the system clock. the crystal valid flag (xtlvld in register oscxcn) is set to 1 by hardware when the external oscillator is settled. to avoid reading a false xtlvld,in crystal mode software should delay at least 1 ms between enabling the external oscillator and checking xtlvld. rc and c modes typically require no startup time. table 14.1. internal oscillator electrical characteristics -40c to +85c unless otherwise specified parameter conditions min typ max units calibrated internal oscillator frequency 24 24.5 25 mhz internal oscillator supply current (from vdd) oscicn.7 = 1 tbd a figure 14.4. clksel: oscillator clock selection register bits7-1: reserved. bit0: clksl: system clock source select bit. 0: sysclk derived from the internal oscillator,and scaled as per the ifcn bits in oscicn. 1: sysclk derived from the external oscillator circuit. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue - - - - - - - clksl 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x97 f
page 164 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 14.5. oscxcn: external oscillator control register bit7: xtlvld: crystal oscillator valid flag. ( valid only when xoscmd = 11x. ). 0: crystal oscillator is unused or not yet stable. 1: crystal oscillator is running and stable. bits6-4: xoscmd2-0: external oscillator mode bits. 00x: external oscillator circuit off. 010: external cmos clock mode (external cmos clock input on xtal1 pin). 011: external cmos clock mode with divide by 2 stage (external cmos clock input on xtal1 pin). 10x: rc/c oscillator mode with divide by 2 stage. 110: crystal oscillator mode. 111: crystal oscillator mode with divide by 2 stage. bit3: unused. read = 0,write = don't care. bits2-0: xfcn2-0: external oscillator frequency control bits. 000-111: see table below: crystal mode (circuit from figure 14.1,option 1; xoscmd = 11x). choose xfcn value to match crystal frequency. rc mode (circuit from figure 14.1,option 2; xoscmd = 10x). choose xfcn value to match frequency range: f=1.23(10 3 )/(r*c) ,where f = frequency of oscillation in mhz c = capacitor value in pf r = pull-up resistor value in k ? cmode (circuit from figure 14.1,option 3; xoscmd = 10x). choose k factor (kf) for the oscillation frequency desired: f = kf / (c * vdd) ,where f = frequency of oscillation in mhz c = capacitor value on xtal1,xtal2 pins in pf r r/w r/w r/w r r/w r/w r/w reset value xtlvld xoscmd2 xoscmd1 xoscmd0 - xfcn2 xfcn1 xfcn0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x8c f xfcn crystal (xoscmd = 11x) rc (xoscmd = 10x) c (xoscmd = 10x) 000 f 32khz f 25khz k factor = 0.87 001 32khz < f 84khz 25khz < f 50khz k factor = 2.6 010 84khz < f 225khz 50khz < f 100khz k factor = 7.7 011 225khz < f 590khz 100khz < f 200khz k factor = 22 100 590khz < f 1.5mhz 200khz < f 400khz k factor = 65 101 1.5mhz < f 4mhz 400khz < f 800khz k factor = 180 110 4mhz < f 10mhz 800khz < f 1.6mhz k factor = 664 111 10mhz < f 30mhz 1.6mhz < f 3.2mhz k factor = 1590
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 165 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 14.4. external crystal example if a crystal or ceramic resonator is used as an external oscillator source for the mcu,the circuit should be configured as shown in figure 14.1,option 1. the external oscillator frequency control value (xfcn) should be chosen from the crystal column of the table in figure 14.5 (oscxcn register). for example,an 11.0592 mhz crystal requires an xfcn setting of 111b. when the crystal oscillator is enabled,the oscillator amplitude detection circuit requires a settle time to achieve proper bias. introducing a blanking interval of at least 1 ms between enabling the oscillator and checking the xtlvld bit will prevent a premature switch to the external oscillator as the system clock. switching to the external oscillator before the crystal oscillator has stabilized can result in unpredictable behavior. the recommended proce- dure is: step 1. enable the external oscillator. step 2. wait at least1 ms. step 3. poll for xtlvld => 1. step 4. switch the system clock to the external oscillator. important note on external crystals: crystal oscillator circuits are quite sensitive to pcb layout and external noise. the crystal should be placed as close as possible to the xtal pins on the device. the traces should be as short as possible and shielded with ground plane from any other traces which could introduce noise or interference. crystal loading capacitors should be referenced to agnd. 14.5. external rc example if an rc network is used as an external oscillator source for the mcu,the circuit should be configured as shown in figure 14.1,option 2. the capacitor should be no greater than 100 pf; however for very small capacitors,the total capacitance may be dominated by parasitic capacitance in the pcb layout. to determine the required external oscil- lator frequency control value (xfcn) in the oscxcn register,first select the rc network value to produce the desired frequency of oscillation. if the frequency desired is 100 khz,let r = 246 k ? andc=50pf: f=1.23(10 3 )/rc=1.23(10 3 ) / [ 246 * 50 ] = 0.1 mhz = 100 khz referring to the table in figure 14.5,the required xfcn setting is 010. 14.6. external capacitor example if a capacitor is used as an external oscillator for the mcu,the circuit should be configured as shown in figure 14.1, option 3. the capacitor should be no greater than 100 pf; however for very small capacitors,the total capacitance may be dominated by parasitic capacitance in the pcb layout. to determine the required external oscillator fre- quency control value (xfcn) in the oscxcn register,select the capacitor to be used and find the frequency of oscillation from the equations below. assume vdd = 3.0 v and c = 50 pf: f = kf / ( c * vdd ) = kf / ( 50 * 3 ) f = kf / 150 if a frequency of roughly 50 khz is desired,select the k factor from the table in figure 14.5 as kf = 7.7: f = 7.7 / 150 = 0.051 mhz,or 51 khz therefore,the xfcn value to use in this example is 010.
page 166 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n notes
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 167 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 15. flash memory the C8051F060/1/2/3 family includes 64k + 128 bytes of on-chip,reprogrammable flash memory for program code and non-volatile data storage. the flash memory can be programmed in-system,a single byte at a time, through the jtag interface or by software using the movx write instructions. once cleared to logic 0,a flash bit must be erased to set it back to logic 1. the bytes would typically be erased (set to 0xff) before being reprogrammed. flash write and erase operations are automatically timed by hardware for proper execution; data polling to deter- mine the end of the write/erase operation is not required. the cpu is stalled during write/erase operations while the device peripherals remain active. interrupts that occur during flash write/eraee operations are held,and are then serviced in their priority order once the flash operation has completed. refer to table 15.1 for the electrical char- acteristics of the flash memory. 15.1. programming the flash memory the simplest means of programming the flash memory is through the jtag interface using programming tools provided by cygnal or a third party vendor. this is the only means for programming a non-initialized device. for details on the jtag commands to program flash memory,see section 25. jtag (ieee 1149.1) on page 301 . the flash memory can be programmed from software using the movx write instruction with the address and data byte to be programmed provided as normal operands. before writing to flash memory using movx,flash write operations must be enabled by setting the pswe program store write enable bit (psctl.0) to logic 1. this directs the movx writes to flash memory instead of to xram,which is the default target. the pswe bit remains set until cleared by software. to avoid errant flash writes,it is recommended that interrupts be disabled while the pswe bit is logic 1. flash memory is read using the movc instruction. movx reads are always directed to xram,regardless of the state of pswe. note : to ensure the integrity of flash memory contents, it is strongly recommended that the on-chip vdd monitor be enabled by connecting the vdd monitor enable pin (monen) to vdd in any system that writes and/or erases flash memory from software. see reset sources on page 155 for more information. a write to flash memory can clear bits but cannot set them; only an erase operation can set bits in flash. abyte location to be programmed must be erased before a new value can be written . the 64k byte flash memory is organized in 512-byte pages. the erase operation applies to an entire page (setting all bytes in the page to 0xff). the following steps illustrate the algorithm for programming flash from user software. step 1. disable interrupts. step 2. set flwe (flscl.0) to enable flash writes/erases via user software. step 3. set psee (psctl.1) to enable flash erases. step 4. set pswe (psctl.0) to redirect movx commands to write to flash. step5. usethemovxcommandtowriteadatabytetoanylocationwithinthe512-bytepagetobeerased. step 6. clear psee to disable flash erases step 7. use the movx command to write a data byte to the desired byte location within the erased 512-byte page. repeat this step until all desired bytes are written (within the target page). step 8. clear the pswe bit to redirect movx commands to the xram data space. step 9. re-enable interrupts.
page 168 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n write/erase timing is automatically controlled by hardware. note that code execution in the 8051 is stalled while the flash is being programmed or erased. table 15.1. flash electrical characteristics parameter conditions min typ max units endurance 20k 100k erase/write erase cycle time 10 12 14 ms write cycle time 40 50 60 s
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 169 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 15.2. non-volatile data storage the flash memory can be used for non-volatile data storage as well as program code. this allows data such as cal- ibration coefficients to be calculated and stored at run time. data is written using the movx write instruction (as described in the previous section) and read using the movc instruction. an additional 128-byte sector of flash memory is included for non-volatile data storage. its smaller sector size makes it particularly well suited as general purpose,non-volatile scratchpad memory. even though flash memory can be written a single byte at a time,an entire sector must be erased first. in order to change a single byte of a multi- byte data set,the data must be moved to temporary storage. the 128-byte sector-size facilitates updating data without wasting program memory or ram space. the 128-byte sector is double-mapped over the 64k byte flash memory; its address ranges from 0x00 to 0x7f (see figure 15.1). to access this 128-byte sector,the sfle bit in psctl must be set to logic 1. code execution from this 128-byte scratchpad sector is not permitted. 15.3. security options the cip-51 provides security options to protect the flash memory from inadvertent modification by software as well as prevent the viewing of proprietary program code and constants. the program store write enable (psctl.0) and the program store erase enable (psctl.1) bits protect the flash memory from accidental modification by software. these bits must be explicitly set to logic 1 before software can write or erase the flash memory. addi- tional security features prevent proprietary program code and data constants from being read or altered across the jtag interface or by software running on the system controller. a set of security lock bytes stored at 0xfbfe and 0xfbff protect the flash program memory from being read or altered across the jtag interface. each bit in a security lock-byte protects one 8k-byte block of memory. clearing a bit to logic 0 in a read lock byte prevents the corresponding block of flash memory from being read across the jtag interface. clearing a bit in the write/erase lock byte protects the block from jtag erasures and/or writes. the read lock byte is at location 0xfbff. the write/erase lock byte is located at 0xfbfe. figure 15.1 shows the location and bit definitions of the security bytes. the 512-byte sector containing the lock bytes can be written to,but not erased by software. an attempted read of a read-locked byte returns undefined data. debugging code in a read- locked sector is not possible through the jtag interface. note: to ensure protection from external access, the block containing the lock bytes (0xfa00-0xfbff) must be write/erase locked by clearing the msb of byte 0xfbfe.
page 170 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n the lock bits can always be read and cleared to logic 0 regardless of the security setting applied to the block contain- ing the security bytes. this allows additional blocks to be protected after the block containing the security bytes has been locked. important note: the only means of removing a lock once the msb of the write/erase security byte is set is to erase the entire program memory space by performing a jtag erase operation (i.e. cannot be done in user firmware). addressing either security byte while performing a jtag erase operation will automati- cally initiate erasure of the entire program memory space (except for the reserved area). this erasure can only be performed via jtag. if a non-security byte in the 0xfa00-0xfbff page is addressed during the jtag era- sure, only that page (including the security bytes) will be erased. the flash access limit security feature (see figure 15.1) protects proprietary program code and data from being read by software running on the C8051F060/1/2/3. this feature provides support for oems that wish to program the 0xfc00 0xfbfe program/data memory space 0x0000 0xfbff read lock byte write/erase lock byte software read limit reserved 0xffff 0xfbfd sfle = 0 bit memory block 7 6 5 4 0xc000 - 0xdfff 0xe000 - 0xfbfd 0xa000 - 0xbfff 0x8000 - 0x9fff 3 2 1 0 0x4000 - 0x5fff 0x6000 - 0x7fff 0x2000 - 0x3fff 0x0000 - 0x1fff read and write/erase security bits. (bit 7 is msb.) 0x007f 0x0000 scratchpad memory (data only) sfle = 1 figure 15.1. flash program memory map and security bytes flashreadlockbyte bits7-0: each bit locks a corresponding block of memory. (bit7 is msb). 0: read operations are locked (disabled) for corresponding block across the jtag interface. 1: read operations are unlocked (enabled) for corresponding block across the jtag interface. flash write/erase lock byte bits7-0: each bit locks a corresponding block of memory. 0: write/erase operations are locked (disabled) for corresponding block across the jtag interface. 1: write/erase operations are unlocked (enabled) for corresponding block across the jtag interface. note: when the highest block is locked,the security bytes may be written but not erased. flash access limit register (flacl) the content of this register is used as the high byte of the 16-bit software read limit address. this 16- bit read limit address value is calculated as 0xnn00 where nn is replaced by content of this register on reset. software running at or above this address is prohibited from using the movx and movc instructions to read,write,or erase flash locations below this address. any attempts to read loca- tions below this limit will return the value 0x00.
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 171 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information mcu with proprietary value-added firmware before distribution. the value-added firmware can be protected while allowing additional code to be programmed in remaining program memory space later. the software read limit (srl) is a 16-bit address that establishes two logical partitions in the program memory space. the first is an upper partition consisting of all the program memory locations at or above the srl address,and the second is a lower partition consisting of all the program memory locations starting at 0x0000 up to (but exclud- ing) the srl address. software in the upper partition can execute code in the lower partition,but is prohibited from reading locations in the lower partition using the movc instruction. (executing a movc instruction from the upper partition with a source address in the lower partition will always return a data value of 0x00.) software running in the lower partition can access locations in both the upper and lower partition without restriction. the value-added firmware should be placed in the lower partition. on reset,control is passed to the value-added firmware via the reset vector. once the value-added firmware completes its initial execution,it branches to a predeter- mined location in the upper partition. if entry points are published,software running in the upper partition may exe- cute program code in the lower partition,but it cannot read the contents of the lower partition. parameters may be passed to the program code running in the lower partition either through the typical method of placing them on the stack or in registers before the call or by placing them in prescribed memory locations in the upper partition. the srl address is specified using the contents of the flash access register. the 16-bit srl address is calculated as 0xnn00,where nn is the contents of the srl security register. thus,the srl can be located on 256-byte bound- aries anywhere in program memory space. however,the 512-byte erase sector size essentially requires that a 512 boundary be used. the contents of a non-initialized srl security byte is 0x00,thereby setting the srl address to 0x0000 and allowing read access to all locations in program memory space by default. bits 7-0: flacl: flash access limit. this register holds the high byte of the 16-bit program memory read/write/erase limit address. the entire 16-bit access limit address value is calculated as 0xnn00 where nn is replaced by contents of flacl. a write to this register sets the flash access limit. this register can only be written once after any reset. any subsequent writes are ignored until the next reset. to fully protect all addresses below this limit,bit 0 of flacl should be set to 0. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr address: sfr page: 0xb7 f figure 15.2. flacl: flash access limit
page 172 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 15.3. flscl: flash memory control bit 7: fose: flash one-shot timer enable this is the timer that turns off the sense amps after a flash read. 0: flash one-shot timer disabled. 1: flash one-shot timer enabled (recommended setting.) bit 6: frae: flash read always enable 0: flash reads occur as necessary (recommended setting.). 1: flash reads occur every system clock cycle. bits 5-1: reserved. read = 00000b. must write 00000b. bit 0: flwe: flash write/erase enable this bit must be set to allow flash writes/erases from user software. 0: flash writes/erases disabled. 1: flash writes/erases enabled. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue fose frae reserved reserved reserved reserved reserved flwe 10000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr address: sfr page: 0xb7 0
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 173 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 15.4. psctl: program store read/write control bits 7-3: unused. read = 00000b,write = don't care. bit 2: sfle: scratchpad flash memory access enable when this bit is set,flash movc reads and writes from user software are directed to the 128-byte scratchpad flash sector. when sfle is set to logic 1,flash accesses out of the address range 0x00-0x7f should not be attempted. reads/writes out of this range will yield undefined results. 0: flash access from user software directed to the 64k byte program/data flash sector. 1: flash access from user software directed to the 128 byte scratchpad sector. bit 1: psee: program store erase enable. setting this bit allows an entire page of the flash program memory to be erased provided the pswe bit is also set. after setting this bit,a write to flash memory using the movx instruction will erase the entire page that contains the location addressed by the movx instruction. the value of the data byte written does not matter. note: the flash page containing the read lock byte and write/erase lock byte cannot be erased by software. 0: flash program memory erasure disabled. 1: flash program memory erasure enabled. bit 0: pswe: program store write enable. setting this bit allows writing a byte of data to the flash program memory using the movx write instruction. the location must be erased prior to writing data. 0: write to flash program memory disabled. movx write operations target external ram. 1: write to flash program memory enabled. movx write operations target flash memory. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue - - - - - sfle psee pswe 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr address: sfr page: 0x8f 0
page 174 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n notes
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 175 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 16. external data memory interface and on-chip xram the C8051F060/1/2/3 mcus include 4k bytes of on-chip ram mapped into the external data memory space (xram). in addition,the C8051F060/2 include an external data memory interface which can be used to access off- chip memories and memory-mapped devices connected to the gpio ports. the external memory space may be accessed using the external move instruction (movx) and the data pointer (dptr),or using the movx indirect addressing mode using r0 or r1. if the movx instruction is used with an 8-bit address operand (such as @r1),then the high byte of the 16-bit address is provided by the external memory interface control register (emi0cn,shown in figure 16.1). note: the movx instruction can also be used for writing to the flash memory. see section 15. flash memory on page 167 for details. the movx instruction accesses xram by default. 16.1. accessing xram the xram memory space (both internal and external) is accessed using the movx instruction. the movx instruc- tion has two forms,both of which use an indirect addressing method. the first method uses the data pointer,dptr, a 16-bit register which contains the effective address of the xram location to be read or written. the second method uses r0 or r1 in combination with the emi0cn register to generate the effective xram address. examples of both of these methods are given below. 16.1.1. 16-bit movx example the 16-bit form of the movx instruction accesses the memory location pointed to by the contents of the dptr reg- ister. the following series of instructions reads the value of the byte at address 0x1234 into the accumulator a: mov dptr, #1234h ; load dptr with 16-bit address to read (0x1234) movx a, @dptr ; load contents of 0x1234 into accumulator a the above example uses the 16-bit immediate mov instruction to set the contents of dptr. alternately,the dptr can be accessed through the sfr registers dph,which contains the upper 8-bits of dptr,and dpl,which contains the lower 8-bits of dptr. 16.1.2. 8-bit movx example the 8-bit form of the movx instruction uses the contents of the emi0cn sfr to determine the upper 8-bits of the effective address to be accessed and the contents of r0 or r1 to determine the lower 8-bits of the effective address to be accessed. the following series of instructions read the contents of the byte at address 0x1234 into the accumulator a. mov emi0cn, #12h ; load high byte of address into emi0cn mov r0, #34h ; load low byte of address into r0 (or r1) movx a, @r0 ; load contents of 0x1234 into accumulator a
page 176 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 16.2. configuring the external memory interface configuring the external memory interface consists of four steps: 1. enable the emif on the high ports (p7,p6,p5,and p4). 2. configure the output modes of the port pins as either push-pull or open-drain (push-pull is most com- mon). 3. configure port latches to park the emif pins in a dormant state (usually by setting them to logic 1). 4. select multiplexed mode or non-multiplexed mode. 5. select the memory mode (on-chip only,split mode without bank select,split mode with bank select,or off-chip only). 6. set up timing to interface with off-chip memory or peripherals. each of these four steps is explained in detail in the following sections. the port enable bit,multiplexed mode selec- tion,and mode bits are located in the emi0cf register shown in figure 16.2. 16.3. port selection and configuration when enabled,the external memory interface appears on ports 7,6,5,and 4 in non-multiplexed mode,or ports 7,6, and 4 in multiplexed mode. the external memory interface claims the associated port pins for memory operations only during the execution of an off-chip movx instruction. once the movx instruction has completed,control of the port pins reverts to the port latches. see section 17. port input/output on page 191 for more information about the port operation and configuration. the port latches should be explicitly configured to park the external memory interface pins in a dormant state, most commonly by setting them to a logic 1 . during the execution of the movx instruction,the external memory interface will explicitly disable the drivers on all port pins that are acting as inputs (data[7:0] during a read operation,for example). the output mode of the port pins (whether the pin is configured as open-drain or push-pull) is unaffected by the external memory interface oper- ation,and remains controlled by the pnmdout registers. see section 17. port input/output on page 191 for more information about port output mode configuration.
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 177 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 16.1. emi0cn: external memory interface control bits7-0: pgsel[7:0]: xram page select bits. the xram page select bits provide the high byte of the 16-bit external data memory address when using an 8-bit movx command,effectively selecting a 256-byte page of ram. 0x00: 0x0000 to 0x00ff 0x01: 0x0100 to 0x01ff ... 0xfe: 0xfe00 to 0xfeff 0xff: 0xff00 to 0xffff r/wr/wr/wr/wr/wr/wr/wr/wresetvalue pgsel7 pgsel6 pgsel5 pgsel4 pgsel3 pgsel2 pgsel1 pgsel0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xa2 0 figure 16.2. emi0cf: external memory configuration bits7-6: unused. read = 00b. write = dont care. bit5: prtsel: emif port select. 0: emif not mapped to port pins. 1: emif active on p4-p7. bit4: emd2: emif multiplex mode select. 0: emif operates in multiplexed address/data mode. 1: emif operates in non-multiplexed mode (separate address and data pins). bits3-2: emd1-0: emif operating mode select. these bits control the operating mode of the external memory interface. 00: internal only: movx accesses on-chip xram only. all effective addresses alias to on-chip memory space. 01: split mode without bank select: accesses below the 4k boundary are directed on-chip. accesses above the 4k boundary are directed off-chip. 8-bit off-chip movx operations use the current contents of the address high port latches to resolve upper address byte. note that in order to access off-chip space,emi0cn must be set to a page that is not contained in the on-chip address space. 10: split mode with bank select: accesses below the 4k boundary are directed on-chip. accesses above the 4k boundary are directed off-chip. 8-bit off-chip movx operations use the contents of emi0cn to determine the high-byte of the address. 11: external only: movx accesses off-chip xram only. on-chip xram is not visible to the cpu. bits1-0: eale1-0: ale pulse-width select bits (only has effect when emd2 = 0). 00: ale high and ale low pulse width = 1 sysclk cycle. 01: ale high and ale low pulse width = 2 sysclk cycles. 10: ale high and ale low pulse width = 3 sysclk cycles. 11: ale high and ale low pulse width = 4 sysclk cycles. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue - - prtsel emd2 emd1 emd0 eale1 eale0 00000011 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xa3 0
page 178 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 16.4. multiplexed and non-multiplexed selection the external memory interface is capable of acting in a multiplexed mode or a non-multiplexed mode,depending on the state of the emd2 (emi0cf.4) bit. 16.4.1. multiplexed configuration in multiplexed mode,the data bus and the lower 8-bits of the address bus share the same port pins: ad[7:0]. in this mode,an external latch (74hc373 or equivalent logic gate) is used to hold the lower 8-bits of the ram address. the external latch is controlled by the ale (address latch enable) signal,which is driven by the external memory inter- face logic. an example of a multiplexed configuration is shown in figure 16.3. in multiplexed mode,the external movx operation can be broken into two phases delineated by the state of the ale signal. during the first phase,ale is high and the lower 8-bits of the address bus are presented to ad[7:0]. during this phase,the address latch is configured such that the q outputs reflect the states of the d inputs. when ale falls,signaling the beginning of the second phase,the address latch outputs remain fixed and are no longer dependent on the latch inputs. later in the second phase,the data bus controls the state of the ad[7:0] port at the time /rd or / wr is asserted. see section 16.6.2. multiplexed mode on page 186 for more information. address/data bus address bus e m i f a[15:8] (p6) ad[7:0] (p7) /wr (p4.7) /rd (p4.6) ale (p4.5) 64k x 8 sram oe we i/o[7:0] 74hc373 g dq a[15:8] a[7:0] ce v dd 8 (optional) figure 16.3. multiplexed configuration example
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 179 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 16.4.2. non-multiplexed configuration in non-multiplexed mode,the data bus and the address bus pins are not shared. an example of a non-multiplexed configuration is shown in figure 16.4. see section 16.6.1. non-multiplexed mode on page 183 for more infor- mation about non-multiplexed operation. address bus e m i f a[15:0] (p5 and p6) 64k x 8 sram a[15:0] data bus d[7:0] (p7) i/o[7:0] v dd 8 /wr (p4.7) /rd (p4.6) oe we ce (optional) figure 16.4. non-multiplexed configuration example
page 180 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 16.5. memory mode selection the external data memory space can be configured in one of four modes,shown in figure 16.5,based on the emif mode bits in the emi0cf register (figure 16.2). these modes are summarized below. more information about the different modes can be found in section 16.6. timing on page 182 . 16.5.1. internal xram only when emi0cf.[3:2] are set to 00,all movx instructions will target the internal xram space on the device. mem- ory accesses to addresses beyond the populated space will wrap on 4k boundaries. as an example,the addresses 0x1000 and 0x2000 both evaluate to address 0x0000 in on-chip xram space. ? 8-bit movx operations use the contents of emi0cn to determine the high-byte of the effective address and r0 or r1 to determine the low-byte of the effective address. ? 16-bit movx operations use the contents of the 16-bit dptr to determine the effective address. 16.5.2. split mode without bank select when emi0cf.[3:2] are set to 01,the xram memory map is split into two areas,on-chip space and off-chip space. ? effective addresses below the 4k boundary will access on-chip xram space. ? effective addresses beyond the 4k boundary will access off-chip space. ? 8-bit movx operations use the contents of emi0cn to determine whether the memory access is on-chip or off- chip. however,in the no bank select mode,an 8-bit movx operation will not drive the upper 8-bits a[15:8] of the address bus during an off-chip access. this allows the user to manipulate the upper address bits at will by setting the port state directly. this behavior is in contrast with split mode with bank select described below. the lower 8-bits of the address bus a[7:0] are driven,determined by r0 or r1. ? 16-bit movx operations use the contents of dptr to determine whether the memory access is on-chip or off- chip,and unlike 8-bit movx operations,the full 16-bits of the address bus a[15:0] are driven during the off- chip transaction. emi0cf[3:2] = 00 0xffff 0x0000 emi0cf[3:2] = 11 0xffff 0x0000 emi0cf[3:2] = 01 0xffff 0x0000 emi0cf[3:2] = 10 on-chip xram on-chip xram on-chip xram on-chip xram on-chip xram on-chip xram off-chip memory (no bank select) on-chip xram 0xffff 0x0000 off-chip memory (bank select) on-chip xram off-chip memory figure 16.5. emif operating modes
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 181 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 16.5.3. split mode with bank select when emi0cf.[3:2] are set to 10,the xram memory map is split into two areas,on-chip space and off-chip space. ? effective addresses below the 4k boundary will access on-chip xram space. ? effective addresses beyond the 4k boundary will access off-chip space. ? 8-bit movx operations use the contents of emi0cn to determine whether the memory access is on-chip or off- chip. the upper 8-bits of the address bus a[15:8] are determined by emi0cn,and the lower 8-bits of the address bus a[7:0] are determined by r0 or r1. all 16-bits of the address bus a[15:0] are driven in bank select mode. ? 16-bit movx operations use the contents of dptr to determine whether the memory access is on-chip or off- chip,and the full 16-bits of the address bus a[15:0] are driven during the off-chip transaction. 16.5.4. external only when emi0cf[3:2] are set to 11,all movx operations are directed to off-chip space. on-chip xram is not visi- ble to the cpu. this mode is useful for accessing off-chip memory located between 0x0000 and the 4k boundary. ? 8-bit movx operations ignore the contents of emi0cn. the upper address bits a[15:8] are not driven (identi- cal behavior to an off-chip access in split mode without bank select described above). this allows the user to manipulate the upper address bits at will by setting the port state directly. the lower 8-bits of the effective address a[7:0] are determined by the contents of r0 or r1. ? 16-bit movx operations use the contents of dptr to determine the effective address a[15:0]. the full 16-bits of the address bus a[15:0] are driven during the off-chip transaction.
page 182 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 16.6. timing the timing parameters of the external memory interface can be configured to enable connection to devices having different setup and hold time requirements. the address setup time,address hold time,/rd and /wr strobe widths, and in multiplexed mode,the width of the ale pulse are all programmable in units of sysclk periods through emi0tc,shown in figure 16.6,and emi0cf[1:0]. assuming non-multiplexed operation,the minimum execution time for an off-chip xram operation is 4 sysclk cycles: 3 cycles for the movx operation + 1 cycle for the /rd or /wr pulse duration. the programmable setup and hold times default to the maximum delay settings after a reset. table 16.1 lists the ac parameters for the external memory interface,and figure 16.7 through figure 16.12 show the timing diagrams for the different external memory interface modes and movx operations. figure 16.6. emi0tc: external memory timing control bits7-6: eas1-0: emif address setup time bits. 00: address setup time = 0 sysclk cycles. 01: address setup time = 1 sysclk cycle. 10: address setup time = 2 sysclk cycles. 11: address setup time = 3 sysclk cycles. bits5-2: ewr3-0: emif /wr and /rd pulse-width control bits. 0000: /wr and /rd pulse width = 1 sysclk cycle. 0001: /wr and /rd pulse width = 2 sysclk cycles. 0010: /wr and /rd pulse width = 3 sysclk cycles. 0011: /wr and /rd pulse width = 4 sysclk cycles. 0100: /wr and /rd pulse width = 5 sysclk cycles. 0101: /wr and /rd pulse width = 6 sysclk cycles. 0110: /wr and /rd pulse width = 7 sysclk cycles. 0111: /wr and /rd pulse width = 8 sysclk cycles. 1000: /wr and /rd pulse width = 9 sysclk cycles. 1001: /wr and /rd pulse width = 10 sysclk cycles. 1010: /wr and /rd pulse width = 11 sysclk cycles. 1011: /wr and /rd pulse width = 12 sysclk cycles. 1100: /wr and /rd pulse width = 13 sysclk cycles. 1101: /wr and /rd pulse width = 14 sysclk cycles. 1110: /wr and /rd pulse width = 15 sysclk cycles. 1111: /wr and /rd pulse width = 16 sysclk cycles. bits1-0: eah1-0: emif address hold time bits. 00: address hold time = 0 sysclk cycles. 01: address hold time = 1 sysclk cycle. 10: address hold time = 2 sysclk cycles. 11: address hold time = 3 sysclk cycles. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue eas1 eas0 erw3 ewr2 ewr1 ewr0 eah1 eah0 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xa1 0
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 183 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 16.6.1. non-multiplexed mode 16.6.1.1. 16-bit movx: emi0cf[4:2] = 101, 110, or 111. emif address (8 msbs) from dph emif address (8 lsbs) from dpl p6 p5 p4.7 p4.6 p7 emif write data p6 p5 p4.7 p4.6 p7 t ach t wdh t acw t acs t wds addr[15:8] addr[7:0] data[7:0] /wr /rd emif address (8 msbs) from dph emif address (8 lsbs) from dpl p6 p5 p4.6 p4.7 p7 p6 p5 p4.6 p4.7 p7 t ach t rdh t acw t acs t rds addr[15:8] addr[7:0] data[7:0] /rd /wr emif read data nonmuxed 16-bit write nonmuxed 16-bit read figure 16.7. non-multiplexed 16-bit movx timing
page 184 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 16.6.1.2. 8-bit movx without bank select: emi0cf[4:2] = 101 or 111. emif address (8 lsbs) from r0 or r1 p6 p5 p4.7 p4.6 p7 emif write data p6 p4.7 p4.6 p7 t ach t wdh t acw t acs t wds addr[15:8] addr[7:0] data[7:0] /wr /rd emif address (8 lsbs) from r0 or r1 p6 p5 p4.6 p4.7 p7 p6 p4.6 p4.7 p7 t ach t rdh t acw t acs t rds addr[15:8] addr[7:0] data[7:0] /rd /wr emif read data nonmuxed 8-bit write without bank select nonmuxed 8-bit read without bank select figure 16.8. non-multiplexed 8-bit movx without bank select timing
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 185 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 16.6.1.3. 8-bit movx with bank select: emi0cf[4:2] = 110. emif address (8 msbs) from emi0cn emif address (8 lsbs) from r0 or r1 p6 p5 p4.7 p4.6 p7 emif write data p6 p5 p4.7 p4.6 p7 t ach t wdh t acw t acs t wds addr[15:8] addr[7:0] data[7:0] /wr /rd emif address (8 msbs) from emi0cn emif address (8 lsbs) from r0 or r1 p6 p5 p4.6 p4.7 p7 p6 p5 p4.6 p4.7 p7 t ach t rdh t acw t acs t rds addr[15:8] addr[7:0] data[7:0] /rd /wr emif read data nonmuxed 8-bit write with bank select nonmuxed 8-bit read with bank select figure 16.9. non-multiplexed 8-bit movx with bank select timing
page 186 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 16.6.2. multiplexed mode 16.6.2.1. 16-bit movx: emi0cf[4:2] = 001, 010, or 011. p7 p6 p7 addr[15:8] ad[7:0] p6 p4.7 p4.6 p4.5 p4.7 p4.6 p4.5 t ach t wdh t acw t acs t wds ale /wr /rd emif address (8 msbs) from dph emif write data emif address (8 lsbs) from dpl t aleh t alel p7 p6 p7 addr[15:8] ad[7:0] p6 p4.6 p4.7 p4.5 p4.6 p4.7 p4.5 t ach t acw t acs ale /rd /wr emif address (8 msbs) from dph emif address (8 lsbs) from dpl t aleh t alel t rdh t rds emif read data muxed 16-bit write muxed 16-bit read figure 16.10. multiplexed 16-bit movx timing
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 187 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 16.6.2.2. 8-bit movx without bank select: emi0cf[4:2] = 001 or 011. p7 p6 p7 addr[15:8] ad[7:0] p4.7 p4.6 p4.5 p4.7 p4.6 p4.5 t ach t wdh t acw t acs t wds ale /wr /rd emif write data emif address (8 lsbs) from r0 or r1 t aleh t alel p7 p6 p7 addr[15:8] ad[7:0] p4.6 p4.7 p4.5 p4.6 p4.7 p4.5 t ach t acw t acs ale /rd /wr emif address (8 lsbs) from r0 or r1 t aleh t alel t rdh t rds emif read data muxed 8-bit write without bank select muxed 8-bit read without bank select figure 16.11. multiplexed 8-bit movx without bank select timing
page 188 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 16.6.2.3. 8-bit movx with bank select: emi0cf[4:2] = 010. p7 p6 p7 addr[15:8] ad[7:0] p6 p4.7 p4.6 p4.5 p4.7 p4.6 p4.5 t ach t wdh t acw t acs t wds ale /wr /rd emif address (8 msbs) from emi0cn emif write data emif address (8 lsbs) from r0 or r1 t aleh t alel p7 p6 p7 addr[15:8] ad[7:0] p6 p4.6 p4.7 p4.5 p4.6 p4.7 p4.5 t ach t acw t acs ale /rd /wr emif address (8 msbs) from emi0cn emif address (8 lsbs) from r0 or r1 t aleh t alel t rdh t rds emif read data muxed 8-bit write with bank select muxed 8-bit read with bank select figure 16.12. multiplexed 8-bit movx with bank select timing
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 189 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information table 16.1. ac parameters for external memory interface parameter descriptionminmax units t sysclk system clock period 40 ns t acs address / control setup time 0 3*t sysclk ns t acw address / control pulse width 1*t sysclk 16*t sysclk ns t ach address / control hold time 0 3*t sysclk ns t aleh address latch enable high time 1*t sysclk 4*t sysclk ns t alel address latch enable low time 1*t sysclk 4*t sysclk ns t wds writedatasetuptime 1*t sysclk 19*t sysclk ns t wdh writedataholdtime 0 3*t sysclk ns t rds read data setup time 20 ns t rdh read data hold time 0 ns
page 190 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n notes
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 191 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 17. port input/output the c8051f06x family of devices are fully integrated mixed-signal system on a chip mcus with 59 digital i/o pins (C8051F060/2) or 24 digital i/o pins (c8051f061/3),organized as 8-bit ports. all ports are both bit- and byte- addressable through their corresponding port data registers. all port pins support configurable open-drain or push- pull output modes and weak pull-ups. additionally,port 0 pins are 5 v-tolerant. a block diagram of the port i/o cell is shown in figure 17.1. complete electrical specifications for the port i/o pins are given in table 17.1. dgnd /port-outenable port-output push-pull vdd vdd /weak-pullup (weak) port pad analog input analog select (port 1 and 2 only) port-input figure 17.1. port i/o cell block diagram table 17.1. port i/o dc electrical characteristics vdd = 2.7 v to 3.6 v,-40c to +85c unless otherwise specified. parameter conditions min typ max units output high voltage (v oh )i oh = -3 ma,port i/o push-pull i oh = -10 a,port i/o push-pull vdd - 0.7 vdd - 0.1 v output low voltage (v ol )i ol =8.5ma i ol =10a 0.6 0.1 v input high voltage (vih) 0.7 x vdd input low voltage (vil) 0.3 x vdd input leakage current dgnd < port pin < vdd,pin tri-state weak pull-up off weak pull-up on 10 1 a input capacitance 5 pf
page 192 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n the c8051f06x family of devices have a wide array of digital resources which are available through the four lower i/ o ports: p0,p1,p2,and (on the C8051F060/2) p3. each of the pins on p0,p1,p2,and p3,can be defined as a gen- eral-purpose i/o (gpio) pin or can be controlled by a digital peripheral or function (like uart0 or /int1 for exam- ple),as shown in figure 17.2. the system designer controls which digital functions are assigned pins,limited only by the number of pins available. this resource assignment flexibility is achieved through the use of a priority crossbar decoder. note that the state of a port i/o pin can always be read from its associated data register regardless of whether that pin has been assigned to a digital peripheral or behaves as gpio. the port pins on ports 1,and 2 can be used as analog inputs to adc2 or the analog voltage comparators,respectively an external memory interface which is active during the execution of a movx instruction whose target address resides in off-chip memory can be active on either the lower ports or the upper ports. see section 16. external data memory interface and on-chip xram on page 175 for more information about the external memory interface. the upper ports (available on C8051F060/2) can be byte-accessed as gpio pins. external pins digital crossbar priority decoder smbus 2 spi 4 uart0 2 pca 2 t0, t1, t2, t2ex, t3, t3ex, t4,t4ex, /int0, /int1 p1.0 p1.7 p2.0 p2.7 p0.0 p0.7 highest priority lowest priority 8 8 comptr. outputs (internal digital signals) highest priority lowest priority uart1 6 2 p3.0 p3.7 8 8 p0mdout, p1mdout, p2mdout, p3mdout registers xbr0, xbr1, xbr2, xbr3 p1mdin, p2mdin, p3mdin registers p1 i/o cells p3 i/o cells p0 i/o cells p2 i/o cells 8 port latches p0 p1 p2 8 8 8 p3 8 (p2.0-p2.7) (p1.0-p1.7) (p0.0-p0.7) (p3.0-p3.7) to adc2 input to comparators /sysclk cnvstr2 C8051F060/2 only figure 17.2. port i/o functional block diagram
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 193 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 17.1. ports 0 through 3 and the priority crossbar decoder the priority crossbar decoder,or crossbar,allocates and assigns port pins on port 0 through port 3 to the digital peripherals (uarts,smbus,pca,timers,etc.) on the device using a priority order. the port pins are allocated in order starting with p0.0 and continue through p3.7 (on the C8051F060/2) or p2.7 (on the c8051f061/3) if necessary. the digital peripherals are assigned port pins in a priority order which is listed in figure 17.3,with uart0 having the highest priority and cnvstr2 having the lowest priority. 17.1.1. crossbar pin assignment and allocation the crossbar assigns port pins to a peripheral if the corresponding enable bits of the peripheral are set to a logic 1 in the crossbar configuration registers xbr0,xbr1,xbr2,and xbr3,shown in figure 17.5,figure 17.6, figure 17.7,and figure 17.8. for example,if the uart0en bit (xbr0.2) is set to a logic 1,the tx0 and rx0 pins will be mapped to p0.0 and p0.1 respectively. because uart0 has the highest priority,its pins will always be mapped to p0.0 and p0.1 when uart0en is set to a logic 1. if a digital peripherals enable bits are not set to a logic 1,then its ports are not accessible at the port pins of the device. also note that the crossbar assigns pins to all figure 17.3. priority crossbar decode table pini/o01234567012345670123456701234567 tx0  rx0  sck  miso  mosi  nss  nss is not assigned to a port pin when the spi is placed in 3-wire mode sda   scl   tx1   rx1   cex0   cex1   cex2   cex3   cex4   cex5   eci  eci0e: xbr0.6 cp0  cp0e: xbr0.7 cp1  cp1e: xbr1.0 cp2  cp2e: xbr3.3 t0  t0e: xbr1.1 /int0  int0e: xbr1.2 t1  t1e: xbr1.3 /int1  int1e: xbr1.4 t2  t2e: xbr1.5 t2ex  t2exe: xbr1.6 t3  t3e: xbr3.0 t3ex  t3exe: xbr3.1 t4  t4e: xbr2.3 t4ex  t4exe: xbr2.4 /sysclk  syscke: xbr1.7 cnvstr2  cnvste2: xbr3.2 ain2.0 ain2.1 ain2.2 ain2.3 ain2.4 ain2.5 ain2.6 ain2.7 cp1+ cp1- cp2+ cp2- cp0+ cp0- xbr2.2 xbr0.[5:3] uart0en: spi0en: uart1en: pca0me: crossba r register bits xbr0.2 xbr0.1 xbr0.0 smb0en: p0 p1 p2 p3
page 194 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n associated functions when the smbus,uart0 or uart1 are selected (i.e. smbus,spi,uart). it would be impos- sible,for example,to assign tx0 to a port pin without assigning rx0 as well. the spi can operate in 3 or 4-wire mode (with or without nss). each combination of enabled peripherals results in a unique device pinout. all port pins on ports 0 through 3 that are not allocated by the crossbar can be accessed as general-purpose i/o (gpio) pins by reading and writing the associated port data registers (see figure 17.9,figure 17.11,figure 17.14, and figure 17.17),a set of sfrs which are both byte- and bit-addressable. the output states of port pins that are allo- cated by the crossbar are controlled by the digital peripheral that is mapped to those pins. writes to the port data reg- isters (or associated port bits) will have no effect on the states of these pins. a read of a port data register (or port bit) will always return the logic state present at the pin itself,regardless of whether the crossbar has allocated the pin for peripheral use or not. an exception to this occurs during the execution of a read-modify-write instruction (anl,orl,xrl,cpl,inc,dec,djnz,jbc,clr,setb,and the bitwise mov write operation). during the read cycle of the read-modify-write instruction,it is the contents of the port data register,not the state of the port pins themselves,which is read. because the crossbar registers affect the pinout of the peripherals of the device,they are typically configured in the initialization code of the system before the peripherals themselves are configured. once configured,the crossbar reg- isters are typically left alone. once the crossbar registers have been properly configured,the crossbar is enabled by setting xbare (xbr2.4) to a logic 1. until xbare is set to a logic 1, the output drivers on ports 0 through 3 are explicitly disabled in order to prevent possible contention on the port pins while the crossbar registers and other registers which can affect the device pinout are being written . the output drivers on crossbar-assigned input signals (like rx0,for example) are explicitly disabled; thus the values of the port data registers and the pnmdout registers have no effect on the states of these pins. 17.1.2. configuring the output modes of the port pins the output drivers on ports 0 through 3 remain disabled until the crossbar is enabled by setting xbare (xbr2.4) to alogic1. the output mode of each port pin can be configured to be either open-drain or push-pull. in the push-pull configura- tion,writing a logic 0 to the associated bit in the port data register will cause the port pin to be driven to gnd,and writing a logic 1 will cause the port pin to be driven to vdd. in the open-drain configuration,writing a logic 0 to the associated bit in the port data register will cause the port pin to be driven to gnd,and a logic 1 will cause the port pin to assume a high-impedance state. the open-drain configuration is useful to prevent contention between devices in systems where the port pin participates in a shared interconnection in which multiple outputs are connected to the same physical wire (like the sda signal on an smbus connection). the output modes of the port pins on ports 0 through 3 are determined by the bits in the associated pnmdout regis- ters (see figure 17.10,figure 17.13,figure 17.16,and figure 17.18). for example,a logic 1 in p3mdout.7 will configure the output mode of p3.7 to push-pull; a logic 0 in p3mdout.7 will configure the output mode of p3.7 to open-drain. all port pins default to open-drain output. the pnmdout registers control the output modes of the port pins regardless of whether the crossbar has allocated the port pin for a digital peripheral or not. the exceptions to this rule are: the port pins connected to sda,scl,rx0 (if uart0 is in mode 0),and rx1 (if uart1 is in mode 0) are always configured as open-drain outputs,regardless of the settings of the associated bits in the pnmdout registers.
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 195 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 17.1.3. configuring port pins as digital inputs a port pin is configured as a digital input by setting its output mode to open-drain and writing a logic 1 to the associated bit in the port data register. for example,p3.7 is configured as a digital input by setting p3mdout.7 to a logic0andp3.7toalogic1. if the port pin has been assigned to a digital peripheral by the crossbar and that pin functions as an input (for example rx0,the uart0 receive pin),then the output drivers on that pin are automatically disabled. 17.1.4. weak pull-ups by default,each port pin has an internal weak pull-up device enabled which provides a resistive connection (about 100 k ? ) between the pin and vdd. the weak pull-up devices can be globally disabled by writing a logic 1 to the weak pull-up disable bit,(weakpud,xbr2.7). the weak pull-up is automatically deactivated on any pin that is driving a logic 0; that is,an output pin will not contend with its own pull-up device. the weak pull-up device can also be explicitly disabled on a port 1 pin by configuring the pin as an analog input,as described below. 17.1.5. configuring port 1 and 2 pins as analog inputs the pins on port 1 can serve as analog inputs to the adc2 analog mux and the pins on port 2 can serve as analog inputs to the comparators. a port pin is configured as an analog input by writing a logic 0 to the associated bit in the pnmdin registers. all port pins default to a digital input mode. configuring a port pin as an analog input: 1. disables the digital input path from the pin. this prevents additional power supply current from being drawn when the voltage at the pin is near vdd / 2. a read of the port data bit will return a logic 0 regardless of the voltage at the port pin. 2. disables the weak pull-up device on the pin. 3. causes the crossbar to skip over the pin when allocating port pins for digital peripherals. note that the output drivers on a pin configured as an analog input are not explicitly disabled. therefore,the associ- ated pnmdout bits of pins configured as analog inputs should explicitly be set to logic 0 (open-drain output mode),and the associated port data bits should be set to logic 1 (high-impedance). also note that it is not required to configure a port pin as an analog input in order to use it as an input to adc2 or the comparators,however,it is strongly recommended. see the analog peripherals corresponding section in this datasheet for further information.
page 196 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 17.1.6. crossbar pin assignment example in this example (figure 17.4),we configure the crossbar to allocate port pins for uart0,the smbus,all 6 pca modules,/int0,and /int1 (12 pins total). additionally,we configure p1.2,p1.3,and p1.4 for analog input mode so that the voltages at these pins can be measured by adc2. the configuration steps are as follows: xbr0,xbr1,and xbr2 are set such that uart0en = 1,smb0en = 1,pca0me = 110,int0e = 1,and int1e = 1. thus: xbr0 = 0x3d,xbr1 = 0x14,and xbr2 = 0x40. 1. we configure the desired port 1 pins to analog input mode by setting p1mdin to 0xe3 (p1.4,p1.3,and p1.2 are analog inputs,so their associated p1mdin bits are set to logic 0). 2. we enable the crossbar by setting xbare = 1: xbr2 = 0x40. - uart0 has the highest priority,so p0.0 is assigned to tx0,and p0.1 is assigned to rx0. - the smbus is next in priority order,so p0.2 is assigned to sda,and p0.3 is assigned to scl. - pca0 is next in priority order,so p0.4 through p1.1 are assigned to cex0 through cex5 - p1mdin is set to 0xe3,which configures p1.2,p1.3,and p1.4 as analog inputs,causing the crossbar to skip these pins. - /int0 is next in priority order,so it is assigned to the next non-skipped pin,which is p1.5. - /int1 is next in priority order,so it is assigned to p1.6. 3. we set the uart0 tx pin (tx0,p0.0) output and the cex0-3 outputs to push-pull by setting p0mdout = 0xf1. 4. we explicitly disable the output drivers on the 3 analog input pins by setting the corresponding bits in the p1mdout register to 0,and in p1 to 1. additionally,the cex5-4 output pins are set to push-pull mode. therefore,p1mdout = 0x03 (configure unused pins to open-drain) and p1 = 0xff (a logic 1 selects the high-impedance state).
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 197 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 17.4. crossbar example: (p1mdin= 0xe3; xbr0 = 0x3d; xbr1 = 0x14; xbr2 = 0x40) pini/o01234567012345670123456701234567 tx0  rx0  sck  miso  mosi  nss  sda    scl    tx1   rx1   cex0     cex1     cex2     cex3     cex4     cex5    eci   eci0e: xbr0.6 cp0   cp0e: xbr0.7 cp1   cp1e: xbr1.0 cp2   cp2e: xbr3.3 t0   t0e: xbr1.1 /int0    int0e: xbr1.2 t1   t1e: xbr1.3 /int1     int1e: xbr1.4 t2   t2e: xbr1.5 t2ex   t2exe: xbr1.6 t3   t3e: xbr3.0 t3ex   t3exe: xbr3.1 t4   t4e: xbr2.3 t4ex   t4exe: xbr2.4 /sysclk   syscke: xbr1.7 cnvstr2   cnvste2: xbr3.2 ain2.0 ain2.1 ain2.2 ain2.3 ain2.4 ain2.5 ain2.6 ain2.7 cp1+ cp1- cp2+ cp2- cp0+ cp0- p0 p1 p2 p3 crossba r register bits xbr0.2 xbr0.1 xbr0.0 smb0en: xbr2.2 xbr0.[5:3] uart0en: spi0en: uart1en: pca0me:
page 198 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 17.5. xbr0: port i/o crossbar register 0 bit7: cp0e: comparator 0 output enable bit. 0: cp0 unavailable at port pin. 1: cp0 routed to port pin. bit6: eci0e: pca0 external counter input enable bit. 0: pca0 external counter input unavailable at port pin. 1: pca0 external counter input (eci0) routed to port pin. bits5-3: pca0me: pca0 module i/o enable bits. 000: all pca0 i/o unavailable at port pins. 001: cex0 routed to port pin. 010: cex0,cex1 routed to 2 port pins. 011: cex0,cex1,and cex2 routed to 3 port pins. 100: cex0,cex1,cex2,and cex3 routed to 4 port pins. 101: cex0,cex1,cex2,cex3,and cex4 routed to 5 port pins. 110: cex0,cex1,cex2,cex3,cex4,and cex5 routed to 6 port pins. bit2: uart0en: uart0 i/o enable bit. 0: uart0 i/o unavailable at port pins. 1: uart0 tx routed to p0.0,and rx routed to p0.1. bit1: spi0en: spi0 bus i/o enable bit. 0: spi0 i/o unavailable at port pins. 4-wire mode: 1: spi0 sck,miso,mosi,and nss routed to 4 port pins. 3-wire mode: 1: spi0 sck,miso and mosi routed to 3 port pins. bit0: smb0en: smbus0 bus i/o enable bit. 0: smbus0 i/o unavailable at port pins. 1: smbus0 sda and scl routed to 2 port pins. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue cp0e eci0e pca0me uart0en spi0en smb0en 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xe1 f
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 199 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 17.6. xbr1: port i/o crossbar register 1 bit7: syscke: /sysclk output enable bit. 0: /sysclk unavailable at port pin. 1: /sysclk routed to port pin. bit6: t2exe: t2ex input enable bit. 0: t2ex unavailable at port pin. 1: t2ex routed to port pin. bit5: t2e: t2 input enable bit. 0: t2 unavailable at port pin. 1: t2 routed to port pin. bit4: int1e: /int1 input enable bit. 0: /int1 unavailable at port pin. 1: /int1 routed to port pin. bit3: t1e: t1 input enable bit. 0: t1 unavailable at port pin. 1: t1 routed to port pin. bit2: int0e: /int0 input enable bit. 0: /int0 unavailable at port pin. 1: /int1 routed to port pin. bit1: t0e: t0 input enable bit. 0: t0 unavailable at port pin. 1: t1 routed to port pin. bit0: cp1e: cp1 output enable bit. 0: cp1 unavailable at port pin. 1: cp1 routed to port pin. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue syscke t2exe t2e int1e t1e int0e t0e cp1e 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xe2 f
page 200 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 17.7. xbr2: port i/o crossbar register 2 bit7: weakpud: weak pull-up disable bit. 0: weak pull-ups globally enabled. 1: weak pull-ups globally disabled. bit6: xbare: crossbar enable bit. 0: crossbar disabled. all pins on ports 0,1,2,and 3,are forced to input mode. 1: crossbar enabled. bit5: unused. read = 0,write = don't care. bit4: t4exe: t4ex input enable bit. 0: t4ex unavailable at port pin. 1: t4ex routed to port pin. bit3: t4e: t4 input enable bit. 0: t4 unavailable at port pin. 1: t4 routed to port pin. bit2: uart1e: uart1 i/o enable bit. 0: uart1 i/o unavailable at port pins. 1: uart1 tx and rx routed to 2 port pins. bits1-0: reserved r/w r/w r/w r/w r/w r/w r/w r/w reset value weakpud xbare - t4exe t4e uart1e - - 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xe3 f
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 201 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 17.8. xbr3: port i/o crossbar register 3 bit7: ctxout: can transmit pin (ctx) output mode. 0: ctx pin output mode is configured as open-drain. 1: ctx pin output mode is configured as push-pull. bit6-4: reserved bit3: cp2e: cp2 output enable bit. 0: cp2 unavailable at port pin. 1: cp2 routed to port pin. bit2: cnvst2e: adc2 external convert start input enable bit. 0: cnvst2 for adc2 unavailable at port pin. 1: cnvst2 for adc2 routed to port pin. bit1: t3exe: t3ex input enable bit. 0: t3ex unavailable at port pin. 1: t3ex routed to port pin. bit0: t3e: t3 input enable bit. 0: t3 unavailable at port pin. 1: t3 routed to port pin. r r r r/wr/wr/wr/wr/wresetvalue ctxout - - cp2e cnvst2e t3exe t3e 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xe4 f
page 202 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 17.9. p0: port0 data register bits7-0: p0.[7:0]: port0 output latch bits. (write - output appears on i/o pins per xbr0,xbr1,xbr2,and xbr3 registers) 0: logic low output. 1: logic high output (open if corresponding p0mdout.n bit = 0). (read - regardless of xbr0,xbr1,xbr2,and xbr3 register settings). 0: p0.n pin is logic low. 1: p0.n pin is logic high. r/w r/w r/w r/w r/w r/w r/w r/w reset value p0.7 p0.6 p0.5 p0.4 p0.3 p0.2 p0.1 p0.0 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0x80 all pages figure 17.10. p0mdout: port0 output mode register bits7-0: p0mdout.[7:0]: port0 output mode bits. 0: port pin output mode is configured as open-drain. 1: port pin output mode is configured as push-pull. note: sda,scl,and rx0 (when uart0 is in mode 0) and rx1 (when uart1 is in mode 0) are always configured as open-drain when they appear on port pins. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xa4 f
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 203 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 17.11. p1: port1 data register bits7-0: p1.[7:0]: port1 output latch bits. (write - output appears on i/o pins per xbr0,xbr1,xbr2,and xbr3 registers) 0: logic low output. 1: logic high output (open if corresponding p1mdout.n bit = 0). (read - regardless of xbr0,xbr1,xbr2,and xbr3 register settings). 0: p1.n pin is logic low. 1: p1.n pin is logic high. note: p1.[7:0] can be configured as inputs to adc2 as ain2.[7:0],in which case they are skipped by the crossbar assignment process and their digital input paths are disabled,depending on p1mdin (see figure 17.12 ) . note that in analog mode,the output mode of the pin is determined by the port 1 latch and p1mdout (figure 17.13). see section 7. 10-bit adc (adc2) on page 83 for more informa- tion about adc2. r/w r/w r/w r/w r/w r/w r/w r/w reset value p1.7 p1.6 p1.5 p1.4 p1.3 p1.2 p1.1 p1.0 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0x90 all pages figure 17.12. p1mdin: port1 input mode register bits7-0: p1mdin.[7:0]: port 1 input mode bits. 0: port pin is configured in analog input mode. the digital input path is disabled (a read from the port bit will always return 0). the weak pull-up on the pin is disabled. 1: port pin is configured in digital input mode. a read from the port bit will return the logic level at the pin. the state of the weak pull-up is determined by the weakpud bit (xbr2.7,see figure 17.7). r/w r/w r/w r/w r/w r/w r/w r/w reset value 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xad f
page 204 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 17.13. p1mdout: port1 output mode register bits7-0: p1mdout.[7:0]: port1 output mode bits. 0: port pin output mode is configured as open-drain. 1: port pin output mode is configured as push-pull. note: sda,scl,and rx0 (when uart0 is in mode 0) and rx1 (when uart1 is in mode 0) are always configured as open-drain when they appear on port pins. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xa5 f figure 17.14. p2: port2 data register bits7-0: p2.[7:0]: port2 output latch bits. (write - output appears on i/o pins per xbr0,xbr1,xbr2,and xbr3 registers) 0: logic low output. 1: logic high output (open if corresponding p2mdout.n bit = 0). (read - regardless of xbr0,xbr1,xbr2,and xbr3 register settings). 0: p2.n pin is logic low. 1: p2.n pin is logic high. r/w r/w r/w r/w r/w r/w r/w r/w reset value p2.7 p2.6 p2.5 p2.4 p2.3 p2.2 p2.1 p2.0 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xa0 all pages
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 205 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 17.15. p2mdin: port2 input mode register bits7-0: p2mdin.[7:0]: port 2 input mode bits. 0: port pin is configured in analog input mode. the digital input path is disabled (a read from the port bit will always return 0). the weak pull-up on the pin is disabled. 1: port pin is configured in digital input mode. a read from the port bit will return the logic level at the pin. the state of the weak pull-up is determined by the weakpud bit (xbr2.7,see figure 17.7). r/w r/w r/w r/w r/w r/w r/w r/w reset value 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xae f figure 17.16. p2mdout: port2 output mode register bits7-0: p2mdout.[7:0]: port2 output mode bits. 0: port pin output mode is configured as open-drain. 1: port pin output mode is configured as push-pull. note: sda,scl,and rx0 (when uart0 is in mode 0) and rx1 (when uart1 is in mode 0) are always configured as open-drain when they appear on port pins. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xa6 f
page 206 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 17.17. p3: port3 data register bits7-0: p3.[7:0]: port3 output latch bits. (write - output appears on i/o pins per xbr0,xbr1,xbr2,and xbr3 registers) 0: logic low output. 1: logic high output (open if corresponding p3mdout.n bit = 0). (read - regardless of xbr0,xbr1,xbr2,and xbr3 register settings). 0: p3.n pin is logic low. 1: p3.n pin is logic high. note: although p3 is not brought out to pins on the c8051f061/3 devices,the port data register is still present and can be used by software. see configuring ports which are not pinned out on page 207. r/w r/w r/w r/w r/w r/w r/w r/w reset value p3.7 p3.6 p3.5 p3.4 p3.3 p3.2 p3.1 p3.0 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xb0 all pages figure 17.18. p3mdout: port3 output mode register bits7-0: p3mdout.[7:0]: port3 output mode bits. 0: port pin output mode is configured as open-drain. 1: port pin output mode is configured as push-pull. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xa7 f
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 207 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 17.2. ports 4 through 7 (C8051F060/2 only) all port pins on ports 4 through 7 can be accessed as general-purpose i/o (gpio) pins by reading and writing the associated port data registers (see figure 17.19,figure 17.21,figure 17.23,and figure 17.25),a set of sfrs which are byte-addressable. note that port 4 has only three pins: p4.5,p4.6,and p4.7. a read of a port data register (or port bit) will always return the logic state present at the pin itself,regardless of whether the crossbar has allocated the pin for peripheral use or not. an exception to this occurs during the execution of a read-modify-write instruction (anl,orl,xrl,cpl,inc,dec,djnz,jbc,clr,setb,and the bitwise mov write operation). during the read cycle of the read-modify-write instruction,it is the contents of the port data register,not the state of the port pins themselves,which is read. 17.2.1. configuring ports which are not pinned out although p3,p4,p5,p6,and p7 are not brought out to pins on the c8051f061/3 devices,the port data registers are still present and can be used by software. because the digital input paths also remain active,it is recommended that these pins not be left in a floating state in order to avoid unnecessary power dissipation arising from the inputs float- ing to non-valid logic levels. this condition can be prevented by any of the following: 1. leave the weak pull-up devices enabled by setting weakpud (xbr2.7) to a logic 0. 2. configure the output modes of p3,p4,p5,p6,and p7 to push-pull by writing 0xff to the associated output mode register (pnmdout). 3. force the output states of p3,p4,p5,p6,and p7 to logic 0 by writing zeros to the port data registers: p3 = 0x00,p4 = 0x00,p5 = 0x00,p6= 0x00,and p7 = 0x00. 17.2.2. configuring the output modes of the port pins the output mode of each port pin can be configured to be either open-drain or push-pull. in the push-pull configura- tion,a logic 0 in the associated bit in the port data register will cause the port pin to be driven to gnd,and a logic 1 will cause the port pin to be driven to vdd. in the open-drain configuration,a logic 0 in the associated bit in the port data register will cause the port pin to be driven to gnd,and a logic 1 will cause the port pin to assume a high- impedance state. the open-drain configuration is useful to prevent contention between devices in systems where the port pin participates in a shared interconnection in which multiple outputs are connected to the same physical wire. the output modes of the port pins on ports 4 through 7 are determined by the bits in their respective pnmdout out- put mode registers. each bit in pnmdout controls the output mode of its corresponding port pin (see figure 17.20, figure 17.22,figure 17.24,and figure 17.26). for example,to place port pin 5.3 in push-pull mode (digital output), set p5mdout.3 to logic 1. all port pins default to open-drain mode upon device reset. 17.2.3. configuring port pins as digital inputs a port pin is configured as a digital input by setting its output mode to open-drain and writing a logic 1 to the associated bit in the port data register. for example,p7.7 is configured as a digital input by setting p7mdout.7 to a logic0andp7.7toalogic1. 17.2.4. weak pull-ups by default,each port pin has an internal weak pull-up device enabled which provides a resistive connection (about 100 k ? ) between the pin and vdd. the weak pull-up devices can be globally disabled by writing a logic 1 to the weak pull-up disable bit,(weakpud,xbr2.7). the weak pull-up is automatically deactivated on any pin that is driving a logic 0; that is,an output pin will not contend with its own pull-up device.
page 208 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 17.2.5. external memory interface if the external memory interface is enabled on the high ports and an off-chip movx operation occurs,the external memory interface will control the output states of the affected port pins during the execution phase of the movx instruction,regardless of the settings of the port data registers. the output configuration of the port pins is not affected by the emif operation,except that read operations will explicitly disable the output drivers on the data bus during the movx execution. see section 16. external data memory interface and on-chip xram on page 175 for more information about the external memory interface.
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 209 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 17.19. p4: port4 data register bits7-5: p4.[7:5]: port4 output latch bits. write - output appears on i/o pins. 0: logic low output. 1: logic high output (open,if corresponding p4mdout.n bit = 0). see figure 17.20. read - returns states of i/o pins. 0: p4.n pin is logic low. 1: p4.n pin is logic high. bits 4-0: reserved. write to 11111. note: p4.7 (/wr),p4.6 (/rd),and p4.5 (ale) can be driven by the external data memory interface. see section 16. external data memory interface and on-chip xram on r/w r/w r/w r/w r/w r/w r/w r/w reset value p4.7p4.6p4.5-----11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xc8 f figure 17.20. p4mdout: port4 output mode register bits7-5: p4mdout.[7:5]: port4 output mode bits. 0: port pin output mode is configured as open-drain. 1: port pin output mode is configured as push-pull. bits 4-0: reserved. write to 00000. r/w r/w r/w r/w r/w r/w r/w r/w reset value -----00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x9c f
page 210 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 17.21. p5: port5 data register bits7-0: p5.[7:0]: port5 output latch bits. write - output appears on i/o pins. 0: logic low output. 1: logic high output (open,if corresponding p5mdout bit = 0). see figure 17.22. read - returns states of i/o pins. 0: p5.n pin is logic low. 1: p5.n pin is logic high. note: p5.[7:0] can be driven by the external data memory interface (as address[15:8] in non-multiplexed mode). see section 16. external data memory interface and on-chip xram on page 175 for more information about the external memory interface. r/w r/w r/w r/w r/w r/w r/w r/w reset value p5.7 p5.6 p5.5 p5.4 p5.3 p5.2 p5.1 p5.0 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xd8 f figure 17.22. p5mdout: port5 output mode register bits7-0: p5mdout.[7:0]: port5 output mode bits. 0: port pin output mode is configured as open-drain. 1: port pin output mode is configured as push-pull. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x9d f
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 211 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 17.23. p6: port6 data register bits7-0: p6.[7:0]: port6 output latch bits. write - output appears on i/o pins. 0: logic low output. 1: logic high output (open,if corresponding p6mdout bit = 0). see figure 17.24. read - returns states of i/o pins. 0: p6.n pin is logic low. 1: p6.n pin is logic high. note: p6.[7:0] can be driven by the external data memory interface (as address[15:8] in multiplexed mode,or as address[7:0] in non-multiplexed mode). see section 16. external data mem- ory interface and on-chip xram on page 175 for more information about the external memory interface. r/w r/w r/w r/w r/w r/w r/w r/w reset value p6.7 p6.6 p6.5 p6.4 p6.3 p6.2 p6.1 p6.0 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xe8 f figure 17.24. p6mdout: port6 output mode register bits7-0: p6mdout.[7:0]: port6 output mode bits. 0: port pin output mode is configured as open-drain. 1: port pin output mode is configured as push-pull. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x9e f
page 212 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 17.25. p7: port7 data register bits7-0: p7.[7:0]: port7 output latch bits. write - output appears on i/o pins. 0: logic low output. 1: logic high output (open,if corresponding p7mdout bit = 0). see figure 17.26. read - returns states of i/o pins. 0: p7.n pin is logic low. 1: p7.n pin is logic high. note: p7.[7:0] can be driven by the external data memory interface (as ad[7:0] in multiplexed mode,or as d[7:0] in non-multiplexed mode). see section 16. external data memory interface and on-chip xram on page 175 for more information about the external memory interface. r/w r/w r/w r/w r/w r/w r/w r/w reset value p7.7 p7.6 p7.5 p7.4 p7.3 p7.2 p7.1 p7.0 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xf8 f figure 17.26. p7mdout: port7 output mode register bits7-0: p7mdout.[7:0]: port7 output mode bits. 0: port pin output mode is configured as open-drain. 1: port pin output mode is configured as push-pull. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x9f f
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 213 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 18. controller area network (can0) important documentation note: the bosch can controller is integrated in the c8051f06x family of devices. this section of the data sheet gives a description of the can controller as an overview and offers a descrip- tion of how the cygnal cip-51 mcu interfaces with the on-chip bosch can controller. in order to use the can con- troller, please refer to boschs c_can users manual (revision 1.2) as an accompanying manual to cygnals C8051F060/1/2/3 data sheet. the C8051F060/1/2/3 family of devices feature a control area network (can) controller that enables serial commu- nication using the can protocol. cygnal can controller facilitates communication on a can network in accordance with the bosch specification 2.0a (basic can) and 2.0b (full can). the can controller consists of a can core, message ram (separate from the cip-51 ram),a message handler state machine,and control registers. cygnal can is a protocol controller and does not provide physical layer drivers (i.e.,transceivers). figure 18.2 shows an example typical configuration on a can bus. cygnal can operates at bit rates of up to 1 mbit/second,though this can be limited by the physical layer chosen to transmit data on the can bus. the can processor has 32 message objects that can be configured to transmit or receive data. incoming data,message objects and their identifier masks are stored in the can message ram. all protocol functions for transmission of data and acceptance filtering is performed by the can controller and not by the cip-51 mcu. in this way,minimal cpu bandwidth is needed to use can communication. the cip-51 config- ures the can controller,accesses received data,and passes data for transmission via special function registers (sfr) in the cip-51.
page 214 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n message handler registers message ram (32 message objects) can core tx rx can controller c 8 0 5 1 m c u interrupt s f r 's cantx canrx C8051F060/1/2/3 figure 18.1. cancontroller diagram c8051f06x cantx canrx can_h can_l isolation/buffer (optional) can transceiver isolation/buffer (optional) can transceiver isolation/buffer (optional) can transceiver r r can protocol device can protocol device figure 18.2. typical canbus configuration
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 215 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 18.1. bosch cancontroller operation the can controller featured in the c8051f06x family of devices is a full implementation of boschs full can mod- ule and fully complies with can specification 2.0b. the function and use of the can controller is detailed in the bosch can users guide . the users guide should be used as a reference to configure and use the can controller. this cygnal datasheet describes how to access the can controller. the can control register (can0cn),can test register (can0tst),and can status register (can0sta) in the can controller can be accessed directly or indirectly via cip-51 sfrs. all other can registers must be accessed via an indirect indexing method. see using can0adr,can0dath,and candatl to access can registers on page 217.
page 216 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 18.2. canregisters can registers are classified as follows: 1. can controller protocol registers : can control, interrupt, error control, bus status, test modes. 2. message object interface registers : used to configure 32 message objects, send and receive data to and from message objects. the c8051 mcu accesses the can message ram via the message object interface registers. upon writing a message object number to an if1 or if2 command request register, the contents of the associated interface registers (if1 or if2) will be transferred to or from the message object in can ram. 3. message handler registers : these read only registers are used to provide information to the cip-51 mcu about the message objects (msgvld flags, transmission request pending, new data flags) and interrupts pending (which message objects have caused an interrupt or status interrupt condition). 4. c8051 mcu special function registers (sfr) : five registers located in the c8051 mcu memory map that allow direct access to certain can controller protocol registers, and indexed indirect access to all can registers. 18.2.1. cancontroller protocol registers the can control protocol registers are used to configure the can controller,process interrupts,monitor bus status, and place the controller in test modes. the can controller protocol registers are accessible using c8051 mcu sfrs by an indexed method,and some can be accessed directly by addressing the sfrs in the c8051 sfr map for conve- nience. the registers are: can control register (can0cn),can status register (can0sta),can test register (can0tst),error counter register,bit timing register,and the baud rate prescaler (brp) extension register. can0sta,can0cn,and can0tst can be accessed via c8051 mcu sfrs. all others are accessed indirectly using the can address indexed method via can0adr,can0dath,and can0datl. please refer to the bosch canusers guide for information on the function and use of the cancontrol pro- tocol registers. 18.2.2. message object interface registers there are two sets of message object interface registers used to configure the 32 message objects that transmit and receive data to and from the can bus. message objects can be configured for transmit or receive,and are assigned arbitration message identifiers for acceptance filtering by all can nodes. message objects are stored in message ram,and are accessed and configured using the message object interface registers. these registers are accessed via the c8051s can0adr and can0dat registers using the indirect indexed address method. please refer to the bosch canusers guide for information on the function and use of the message object interface registers. 18.2.3. message handler registers the message handler registers are read only registers. their flags can be read via the indexed access method with can0adr,can0dath,and can0datl. the message handler registers provide interrupt,error,transmit/receive requests,and new data information.
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 217 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information please refer to the bosch canusers guide for information on the function and use of the message handler registers. 18.2.4. cip-51 mcu special function registers c8051f06x family peripherals are modified,monitored,and controlled using special function registers (sfrs). most of the can controller registers cannot be accessed directly using the sfrs. three of the can controllers registers may be accessed directly with sfrs. all other can controller registers are accessed indirectly using three cip-51 mcu sfrs: the can data registers (can0dath and can0datl) and can address register (can0adr). in this way,there are a total of five can registers used to configure and run the can controller. 18.2.5. using can0adr, can0dath, and candatl to access can registers each can controller register has an index number (see table 18.1 below). the can register address space is 128 words (256 bytes). a can register is accessed via the can data registers (can0dath and can0datl) when a can registers index number is placed into the can address register (can0adr). for example,if the bit timing register is to be configured with a new value,can0adr is loaded with 0x03. the low byte of the desired value is accessed using can0datl and the high byte of the bit timing register is accessed using can0dath. can0datl is bit addressable for convenience. to load the value 0x2304 into the bit timing register: can0adr = 0x03; // load bit timing register?s index (table 18.1) can0dath = 0x23; // move the upper byte into data reg high byte can0datl = 0x04; // move the lower byte into data reg low byte note: can0cn,can0sta,and can0tst may be accessed either by using the index method,or by direct access with the cip-51 mcu sfrs. can0cn is located at sfr location 0xf8/sfr page 1 (figure 18.6),can0tst at 0xdb/sfr page 1 (figure 18.7),and can0sta at 0xc0/sfr page 1 (figure 18.8). 18.2.6. can0adr autoincrement feature for ease of programming message objects,can0adr features autoincrementing for the index ranges 0x08 to 0x12 (interface registers 1) and 0x20 to 0x2a (interface registers 2). when the can0adr register has an index in these ranges, the can0adr will autoincrement by 1 to point to the next can register 16-bit word upon a read/write of can0datl . this speeds programming of the frequently programmed interface registers when configuring mes- sage objects. note: table 18.1 below supersedes figure 5 in section 3, programmers model of the bosch canusers guide. table 18.1. canregister index and reset values canregister index register name reset value notes 0x00 can control register 0x0001 accessible in cip-51 sfr map 0x01 status register 0x0000 accessible in cip-51 sfr map 0x02 error register 0x0000 read only 0x03 bit timing register 0x2301 writeenabledbyccebitincan0cn 0x04 interrupt register 0x0000 read only 0x05 test register 0x0000 bit 7 (rx) is determined by can bus 0x06 brp extension register 0x0000 write enabled by test bit in can0cn
page 218 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 0x08 if1 command request 0x0001 can0adr autoincrements in if1 index space (0x08 - 0x12) upon write to can0datl 0x09 if1 command mask 0x0000 can0adr autoincrement upon write to can0datl 0x0a if1 mask 1 0xffff can0adr autoincrement upon write to can0datl 0x0b if1 mask 2 0xffff can0adr autoincrement upon write to can0datl 0x0c if1 arbitration 1 0x0000 can0adr autoincrement upon write to can0datl 0x0d if1 arbitration 2 0x0000 can0adr autoincrement upon write to can0datl 0x0e if1 message control 0x0000 can0adr autoincrement upon write to can0datl 0x0f if1 data a1 0x0000 can0adr autoincrement upon write to can0datl 0x10 if1 data a2 0x0000 can0adr autoincrement upon write to can0datl 0x11 if1 data b1 0x0000 can0adr autoincrement upon write to can0datl 0x12 if1 data b2 0x0000 can0adr autoincrement upon write to can0datl 0x20 if2 command request 0x0001 can0adr autoincrements in if1 index space (0x08 - 0x12) upon write to can0datl 0x21 if2 command mask 0x0000 can0adr autoincrement upon write to can0datl 0x22 if2 mask 1 0xffff can0adr autoincrement upon write to can0datl 0x23 if2 mask 2 0xffff can0adr autoincrement upon write to can0datl 0x24 if2 arbitration 1 0x0000 can0adr autoincrement upon write to can0datl 0x25 if2 arbitration 2 0x0000 can0adr autoincrement upon write to can0datl 0x26 if2 message control 0x0000 can0adr autoincrement upon write to can0datl 0x27 if2 data a1 0x0000 can0adr autoincrement upon write to can0datl 0x28 if2 data a2 0x0000 can0adr autoincrement upon write to can0datl canregister index register name reset value notes
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 219 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 0x29 if2 data b1 0x0000 can0adr autoincrement upon write to can0datl 0x2a if2 data b2 0x0000 can0adr autoincrement upon write to can0datl 0x40 transmission request 1 0x0000 transmission request flags for message objects (read only) 0x41 transmission request 2 0x0000 transmission request flags for message objects (read only) 0x48 new data 1 0x0000 new data flags for message objects (read only) 0x49 new data 2 0x0000 new data flags for message objects (read only) 0x50 interrupt pending 1 0x0000 interrupt pending flags for message objects (read only) 0x51 interrupt pending 2 0x0000 interrupt pending flags for message objects (read only) 0x58 message valid 1 0x0000 message valid flags for message objects (read only) 0x59 message valid 2 0x0000 message valid flags for message objects (read only) canregister index register name reset value notes
page 220 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 18.3. can0dath: can data access register high byte bit7-0: can0dath: can data access register high byte. the can0dat registers are used to read/write register values and data to and from the can regis- ters pointed to with the index number in the can0adr register. the can0adr register is used to point the [can0dath:can0datl] to a desired can register. the desired can registers index number is moved into can0adr. the can0dat register can then read/write to and from the can register. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd9 1 figure 18.4. can0datl: can data access register low byte bit7-0: can0datl: can data access register low byte. the can0dat registers are used to read/write register values and data to and from the can regis- ters pointed to with the index number in the can0adr register. the can0adr register is used to point the [can0dath:can0datl] to a desired can register. the desired can registers index number is moved into can0adr. the can0dat register can then read/write to and from the can register. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd8 1
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 221 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 18.5. can0adr: can address index register bit7-0: can0adr: can address index register. the can0adr register is used to point the [can0dath:can0datl] to a desired can register. the desired can registers index number is moved into can0adr. the can0dat register can then read/write to and from the can register. note : when the value of can0adr is 0x08-0x12 and 0x20-2a (if1 and if2 registers),this register will autoincrement by 1 upon a write to can0datl. see section 18.2.6. can0adr autoincre- ment feature onpage 217 . all canregisters functions/definitions are listed and described in the bosch canusers guide. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xda 1 figure 18.6. can0cn: can control register bit 4: canif: can interrupt flag. write = dont care. 0: can interrupt has not occured. 1: can interrupt has occured and is active. canif is controlled by the can controller and is cleared by hardware once all interrupt conditions have been cleared in the can controller. see section 3.4.1 in the bosch can users guide (page 24) for more information concerning can controller interrupts. *all canregisters functions/definitions are listed and described in the bosch canusers guide with the exception of the canif bit. this register may be accessed directly in the cip-51 sfr register space,or through the indirect,index method (see section 18.2.5. using can0adr, can0dath, and candatl to access can registers onpage 217 ). r/wr/wr/w r r/wr/wr/wr/wresetvalue ***canif**** bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xf8 1
page 222 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 18.7. can0tst: can test register all canregisters functions/definitions are listed and described in the bosch canusers guide. this register may be accessed directly in the cip-51 sfr register space,or through the indirect,index method (see section 18.2.5. using can0adr, can0dath, and candatl to access can registers onpage 217 ). r/wr/wr/wr/wr/wr/wr/wr/wresetvalue please see the bosch can users guide for a complete definition of this register bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xdb 1 figure 18.8. can0sta: can status register all canregisters functions/definitions are listed and described in the bosch canusers guide. this register may be accessed directly in the cip-51 sfr register space,or through the indirect,index method (see section 18.2.5. using can0adr, can0dath, and candatl to access can registers onpage 217 ). r/wr/wr/wr/wr/wr/wr/wr/wresetvalue please see the bosch can users guide for a complete definition of this register bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xc0 1
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 223 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 19. system management bus / i 2 c bus (smbus0) the smbus0 i/o interface is a two-wire,bi-directional serial bus. smbus0 is compliant with the system manage- ment bus specification,version 1.1,and compatible with the i 2 c serial bus. reads and writes to the interface by the system controller are byte oriented with the smbus0 interface autonomously controlling the serial transfer of the data. a method of extending the clock-low duration is available to accommodate devices with different speed capa- bilities on the same bus. smbus0 may operate as a master and/or slave,and may function on a bus with multiple masters. smbus0 provides control of sda (serial data),scl (serial clock) generation and synchronization,arbitration logic,and start/stop control and generation. figure 19.1. smbus0 block diagram sfr bus data path control sfr bus write to smb0dat smbus control logic read smb0dat smb0adr s l v 6 g c s l v 5 s l v 4 s l v 3 s l v 2 s l v 1 s l v 0 c r o s s b a r clock divide logic sysclk smb0cr c r 7 c r 6 c r 5 c r 4 c r 3 c r 2 c r 1 c r 0 scl filter n sda control 0000000b 7 msbs 8 a b a=b 8 0 1 2 3 4 5 6 7 smb0dat 8 smb0cn s t a s i a a f t e t o e e n s m b b u s y s t o smb0sta s t a 4 s t a 3 s t a 2 s t a 1 s t a 0 scl control status generation arbitration scl synchronization scl generation (master mode) irq generation s t a 5 s t a 6 s t a 7 a b a=b smbus irq interrupt request port i/o 1 0 sda filter n 7
page 224 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 19.2 shows a typical smbus configuration. the smbus0 interface will work at any voltage between 3.0 v and 5.0 v and different devices on the bus may operate at different voltage levels. the bi-directional scl (serial clock) and sda (serial data) lines must be connected to a positive power supply voltage through a pull-up resistor or similar circuit. every device connected to the bus must have an open-drain or open-collector output for both the scl and sda lines,so that both are pulled high when the bus is free. the maximum number of devices on the bus is limited only by the requirement that the rise and fall times on the bus will not exceed 300 ns and 1000 ns,respectively. 19.1. supporting documents it is assumed the reader is familiar with or has access to the following supporting documents: 1. the i 2 c-bus and how to use it (including specifications),philips semiconductor. 2. the i 2 c-bus specification -- version 2.0,philips semiconductor. 3. system management bus specification -- version 1.1,sbs implementers forum. 19.2. smbus protocol two types of data transfers are possible: data transfers from a master transmitter to an addressed slave receiver (write),and data transfers from an addressed slave transmitter to a master receiver (read). the master device ini- tiates both types of data transfers and provides the serial clock pulses on scl. note: multiple master devices on the same bus are supported. if two or more masters attempt to initiate a data transfer simultaneously,an arbitration scheme is employed with a single master always winning the arbitration. note that it is not necessary to specify one device as the master in a system; any device who transmits a start and a slave address becomes the master for that transfer. a typical smbus transaction consists of a start condition followed by an address byte (bits7-1: 7-bit slave address; bit0: r/w direction bit),one or more bytes of data,and a stop condition. each byte that is received (by a master or slave) must be acknowledged (ack) with a low sda during a high scl (see figure 19.3). if the receiving device does not ack,the transmitting device will read a not acknowledge (nack),which is a high sda during a high scl. the direction bit (r/w) occupies the least-significant bit position of the address. the direction bit is set to logic 1 to indicate a "read" operation and cleared to logic 0 to indicate a "write" operation. figure 19.2. typical smbus configuration vdd = 5v master device slave device 1 slave device 2 vdd = 3v vdd = 5v vdd = 3v sda scl
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 225 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information all transactions are initiated by a master,with one or more addressed slave devices as the target. the master gener- ates the start condition and then transmits the slave address and direction bit. if the transaction is a write opera- tion from the master to the slave,the master transmits the data a byte at a time waiting for an ack from the slave at the end of each byte. for read operations,the slave transmits the data waiting for an ack from the master at the end of each byte. at the end of the data transfer,the master generates a stop condition to terminate the transaction and free the bus. figure 19.3 illustrates a typical smbus transaction. 19.2.1. arbitration a master may start a transfer only if the bus is free. the bus is free after a stop condition or after the scl and sda lines remain high for a specified time (see section 19.2.4 ). in the event that two or more devices attempt to begin a transfer at the same time,an arbitration scheme is employed to force one master to give up the bus. the master devices continue transmitting until one attempts a high while the other transmits a low. since the bus is open- drain,the bus will be pulled low. the master attempting the high will detect a low sda and give up the bus. the winning master continues its transmission without interruption; the losing master becomes a slave and receives the rest of the transfer. this arbitration scheme is non-destructive: one device always wins,and no data is lost. 19.2.2. clock low extension smbus provides a clock synchronization mechanism,similar to i 2 c,which allows devices with different speed capa- bilities to coexist on the bus. a clock-low extension is used during a transfer in order to allow slower slave devices to communicate with faster masters. the slave may temporarily hold the scl line low to extend the clock low period, effectively decreasing the serial clock frequency. 19.2.3. scl low timeout if the scl line is held low by a slave device on the bus,no further communication is possible. furthermore,the mas- ter cannot force the scl line high to correct the error condition. to solve this problem,the smbus protocol specifies that devices participating in a transfer must detect any clock cycle held low longer than 25 ms as a timeout condi- tion. devices that have detected the timeout condition must reset the communication no later than 10 ms after detect- ing the timeout condition. 19.2.4. scl high (smbus free) timeout the smbus specification stipulates that if the scl and sda lines remain high for more that 50 s,the bus is desig- nated as free. if an smbus device is waiting to generate a master start,the start will be generated following the bus free timeout. sla6 sda sla5-0 r/w d7 d6-0 scl slave address + r/w data byte start ack nack stop figure 19.3. smbus transaction
page 226 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 19.3. smbus transfer modes the smbus0 interface may be configured to operate as a master and/or a slave. at any particular time,the interface will be operating in one of the following modes: master transmitter,master receiver,slave transmitter,or slave receiver. see table 19.1 for transfer mode status decoding using the smb0sta status register. the following mode descriptions illustrate an interrupt-driven smbus0 application; smbus0 may alternatively be operated in polled mode. 19.3.1. master transmitter mode serial data is transmitted on sda while the serial clock is output on scl. smbus0 generates a start condition and then transmits the first byte containing the address of the target slave device and the data direction bit. in this case the data direction bit (r/w) will be logic 0 to indicate a "write" operation. the smbus0 interface transmits one or more bytes of serial data,waiting for an acknowledge (ack) from the slave after each byte. to indicate the end of the serial transfer,smbus0 generates a stop condition. 19.3.2. master receiver mode serial data is received on sda while the serial clock is output on scl. the smbus0 interface generates a start followed by the first data byte containing the address of the target slave and the data direction bit. in this case the data direction bit (r/w) will be logic 1 to indicate a "read" operation. the smbus0 interface receives serial data from the slave and generates the clock on scl. after each byte is received,smbus0 generates an ack or nack depend- ing on the state of the aa bit in register smb0cn. smbus0 generates a stop condition to indicate the end of the serial transfer. a a a s w p data byte data byte sla s=start p=stop a=ack w=write sla = slave address received by smbus interface transmitted by smbus interface interrupt interrupt interrupt interrupt figure 19.4. typical master transmitter sequence data byte data byte a n a s r p sla s = start p=stop a=ack n = nack r=read sla = slave address received by smbus interface transmitted by smbus interface interrupt interrupt interrupt interrupt figure 19.5. typical master receiver sequence
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 227 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 19.3.3. slave transmitter mode serial data is transmitted on sda while the serial clock is received on scl. the smbus0 interface receives a start followed by data byte containing the slave address and direction bit. if the received slave address matches the address held in register smb0adr,the smbus0 interface generates an ack. smbus0 will also ack if the general call address (0x00) is received and the general call address enable bit (smb0adr.0) is set to logic 1. in this case the data direction bit (r/w) will be logic 1 to indicate a "read" operation. the smbus0 interface receives the clock on scl and transmits one or more bytes of serial data,waiting for an ack from the master after each byte. smbus0 exits slave mode after receiving a stop condition from the master. 19.3.4. slave receiver mode serial data is received on sda while the serial clock is received on scl. the smbus0 interface receives a start followed by data byte containing the slave address and direction bit. if the received slave address matches the address held in register smb0adr,the interface generates an ack. smbus0 will also ack if the general call address (0x00) is received and the general call address enable bit (smb0adr.0) is set to logic 1. in this case the data direc- tion bit (r/w) will be logic 0 to indicate a "write" operation. the smbus0 interface receives one or more bytes of serial data; after each byte is received,the interface transmits an ack or nack depending on the state of the aa bit in smb0cn. smbus0 exits slave receiver mode after receiving a stop condition from the master. p r sla s data byte data byte a n a s = start p=stop n=nack r=read sla = slave address received by smbus interface transmitted by smbus interface interrupt interrupt interrupt interrupt figure 19.6. typical slave transmitter sequence p w sla s data byte data byte a a a s=start p=stop a=ack w=write sla = slave address received by smbus interface transmitted by smbus interface interrupt interrupt interrupt interrupt figure 19.7. typical slave receiver sequence
page 228 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 19.4. smbus special function registers the smbus0 serial interface is accessed and controlled through five sfrs: smb0cn control register,smb0cr clock rate register,smb0adr address register,smb0dat data register and smb0sta status register. the five special function registers related to the operation of the smbus0 interface are described in the following sec- tions. 19.4.1. control register the smbus0 control register smb0cn is used to configure and control the smbus0 interface. all of the bits in the register can be read or written by software. two of the control bits are also affected by the smbus0 hardware. the serial interrupt flag (si,smb0cn.3) is set to logic 1 by the hardware when a valid serial interrupt condition occurs. it can only be cleared by software. the stop flag (sto,smb0cn.4) is set to logic 1 by software. it is cleared to logic 0 by hardware when a stop condition is detected on the bus. setting the ensmb flag to logic 1 enables the smbus0 interface. clearing the ensmb flag to logic 0 disables the smbus0 interface and removes it from the bus. momentarily clearing the ensmb flag and then resetting it to logic 1 will reset smbus0 communication. however,ensmb should not be used to temporarily remove a device from the bus since the bus state information will be lost. instead,the assert acknowledge (aa) flag should be used to tempo- rarily remove the device from the bus (see description of aa flag below). setting the start flag (sta,smb0cn.5) to logic 1 will put smbus0 in a master mode. if the bus is free,smbus0 will generate a start condition. if the bus is not free,smbus0 waits for a stop condition to free the bus and then gen- erates a start condition after a 5 s delay per the smb0cr value (in accordance with the smbus protocol,the smbus0 interface also considers the bus free if the bus is idle for 50 s and no stop condition was recognized). if sta is set to logic 1 while smbus0 is in master mode and one or more bytes have been transferred,a repeated start condition will be generated. when the stop flag (sto,smb0cn.4) is set to logic 1 while the smbus0 interface is in master mode,the interface generates a stop condition. in a slave mode,the sto flag may be used to recover from an error condition. in this case,a stop condition is not generated on the bus,but the smbus hardware behaves as if a stop condition has been received and enters the "not addressed" slave receiver mode. note that this simulated stop will not cause the bus to appear free to smbus0. the bus will remain occupied until a stop appears on the bus or a bus free timeout occurs. hardware automatically clears the sto flag to logic 0 when a stop condition is detected on the bus. the serial interrupt flag (si,smb0cn.3) is set to logic 1 by hardware when the smbus0 interface enters one of 27 possible states. if interrupts are enabled for the smbus0 interface,an interrupt request is generated when the si flag is set. the si flag must be cleared by software. important note: if si is set to logic 1 while the scl line is low,the clock-low period of the serial clock will be stretched and the serial transfer is suspended until si is cleared to logic 0. a high level on scl is not affected by the setting of the si flag. the assert acknowledge flag (aa,smb0cn.2) is used to set the level of the sda line during the acknowledge clock cycle on the scl line. setting the aa flag to logic 1 will cause an ack (low level on sda) to be sent during the acknowledge cycle if the device has been addressed. setting the aa flag to logic 0 will cause a nack (high level on sda) to be sent during acknowledge cycle. after the transmission of a byte in slave mode,the slave can be tempo- rarily removed from the bus by clearing the aa flag. the slave's own address and general call address will be ignored. to resume operation on the bus,the aa flag must be reset to logic 1 to allow the slave's address to be recog- nized. setting the smbus0 free timer enable bit (fte,smb0cn.1) to logic 1 enables the timer in smb0cr. when scl goes high,the timer in smb0cr counts up. a timer overflow indicates a free bus timeout: if smbus0 is waiting to
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 229 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information generate a start,it will do so after this timeout. the bus free period should be less than 50 s (see figure 19.9, smbus0 clock rate register). when the toe bit in smb0cn is set to logic 1,timer 4 is used to detect scl low timeouts. if timer 4 is enabled (see section 23.2. timer 2, timer 3, and timer 4 on page 279 ),timer 4 is forced to reload when scl is high, and forced to count when scl is low. with timer 4 enabled and configured to overflow after 25 ms (and toe set),a timer 4 overflow indicates a scl low timeout; the timer 4 interrupt service routine can then be used to reset smbus0 communication in the event of an scl low timeout. figure 19.8. smb0cn: smbus0 control register bit7: busy: busy status flag. 0: smbus0 is free. 1: smbus0 is busy. bit6: ensmb: smbus enable. this bit enables/disables the smbus serial interface. 0: smbus0 disabled. 1: smbus0 enabled. bit5: sta:smbusstartflag. 0: no start condition is transmitted. 1: when operating as a master,a start condition is transmitted if the bus is free. (if the bus is not free,the start is transmitted after a stop is received.) if sta is set after one or more bytes have been transmitted or received and before a stop is received,a repeated start condition is transmit- ted. bit4: sto: smbus stop flag. 0: no stop condition is transmitted. 1: setting sto to logic 1 causes a stop condition to be transmitted. when a stop condition is received,hardware clears sto to logic 0. if both sta and sto are set,a stop condition is transmit- ted followed by a start condition. in slave mode,setting the sto flag causes smbus to behave as if a stop condition was received. bit3: si: smbus serial interrupt flag. this bit is set by hardware when one of 27 possible smbus0 states is entered. (status code 0xf8 does not cause si to be set.) when the si interrupt is enabled,setting this bit causes the cpu to vector to the smbus interrupt service routine. this bit is not automatically cleared by hardware and must be cleared by software. bit2: aa: smbus assert acknowledge flag. this bit defines the type of acknowledge returned during the acknowledge cycle on the scl line. 0: a "not acknowledge" (high level on sda) is returned during the acknowledge cycle. 1: an "acknowledge" (low level on sda) is returned during the acknowledge cycle. bit1: fte: smbus free timer enable bit. 0: no timeout when scl is high. 1: timeout when scl high time exceeds limit specified by the smb0cr value. bit0: toe: smbus timeout enable bit. 0: no timeout when scl is low. 1: timeout when scl low time exceeds limit specified by timer 4,if enabled. r r/wr/wr/wr/wr/wr/wr/wresetvalue busy ensmb sta sto si aa fte toe 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xc0 0
page 230 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 19.4.2. clock rate register figure 19.9. smb0cr: smbus0 clock rate register bits7-0: smb0cr.[7:0]: smbus0 clock rate preset. the smb0cr clock rate register controls the frequency of the serial clock scl in master mode. the 8-bit word stored in the smb0cr register preloads a dedicated 8-bit timer. the timer counts up,and when it rolls over to 0x00,the scl logic state toggles. the smb0cr setting should be bounded by the following equation ,where smb0cr is the unsigned 8-bit value in register smb0cr,and sysclk is the system clock frequency in hz: the resulting scl signal high and low times are given by the following equations: using the same value of smb0cr from above,the bus free timeout period is given in the following equation: r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xcf 0 smb 0 cr 288 ( ( 0.85 C sysclk ) 1.125 ) ? ? < t low 256 smb 0 cr C () sysclk ? = t high 258 smb 0 cr C () sysclk ? 625 ns + ? t bft 10 256 smb 0 cr C () 1 + sysclk ---------------------------------------------------- - ?
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 231 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 19.4.3. data register the smbus0 data register smb0dat holds a byte of serial data to be transmitted or one that has just been received. software can read or write to this register while the si flag is set to logic 1; software should not attempt to access the smb0dat register when the smbus is enabled and the si flag reads logic 0 since the hardware may be in the pro- cess of shifting a byte of data in or out of the register. data in smb0dat is always shifted out msb first. after a byte has been received,the first bit of received data is located at the msb of smb0dat. while data is being shifted out,data on the bus is simultaneously being shifted in. therefore,smb0dat always contains the last data byte present on the bus. in the event of lost arbitration,the transi- tion from master transmitter to slave receiver is made with the correct data in smb0dat. 19.4.4. address register the smb0adr address register holds the slave address for the smbus0 interface. in slave mode,the seven most- significant bits hold the 7-bit slave address. the least significant bit (bit0) is used to enable the recognition of the general call address (0x00). if bit0 is set to logic 1,the general call address will be recognized. otherwise,the general call address is ignored. the contents of this register are ignored when smbus0 is operating in master mode. figure 19.10. smb0dat: smbus0 data register bits7-0: smb0dat: smbus0 data. the smb0dat register contains a byte of data to be transmitted on the smbus0 serial interface or a byte that has just been received on the smbus0 serial interface. the cpu can read from or write to this register whenever the si serial interrupt flag (smb0cn.3) is set to logic 1. when the si flag is not set,the system may be in the process of shifting data and the cpu should not attempt to access this register. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xc2 0 figure 19.11. smb0adr: smbus0 address register bits7-1: slv6-slv0: smbus0 slave address. these bits are loaded with the 7-bit slave address to which smbus0 will respond when operating as a slave transmitter or slave receiver. slv6 is the most significant bit of the address and corresponds to the first bit of the address byte received. bit0: gc: general call address enable. this bit is used to enable general call address (0x00) recognition. 0: general call address is ignored. 1: general call address is recognized. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue slv6 slv5 slv4 slv3 slv2 slv1 slv0 gc 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xc3 0
page 232 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 19.4.5. status register the smb0sta status register holds an 8-bit status code indicating the current state of the smbus0 interface. there are 28 possible smbus0 states,each with a corresponding unique status code. the five most significant bits of the status code vary while the three least-significant bits of a valid status code are fixed at zero when si = 1. therefore, all possible status codes are multiples of eight. this facilitates the use of status codes in software as an index used to branch to appropriate service routines (allowing 8 bytes of code to service the state or jump to a more extensive ser- vice routine). for the purposes of user software,the contents of the smb0sta register is only defined when the si flag is logic 1. software should never write to the smb0sta register; doing so will yield indeterminate results. the 28 smbus0 states,along with their corresponding status codes,are given in table 1.1. figure 19.12. smb0sta: smbus0 status register bits7-3: sta7-sta3: smbus0 status code. these bits contain the smbus0 status code. there are 28 possible status codes; each status code cor- responds to a single smbus state. a valid status code is present in smb0sta when the si flag (smb0cn.3) is set to logic 1. the content of smb0sta is not defined when the si flag is logic 0. writing to the smb0sta register at any time will yield indeterminate results. bits2-0: sta2-sta0: the three least significant bits of smb0sta are always read as logic 0 when the si flag is logic 1. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue sta7 sta6 sta5 sta4 sta3 sta2 sta1 sta0 11111000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xc1 0
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 233 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information table 19.1. smb0sta status codes and states mode status code smbus state typical action mt/ mr 0x08 start condition transmitted. load smb0dat with slave address + r/w. clear sta. 0x10 repeated start condition transmitted. load smb0dat with slave address + r/w. clear sta. master transmitter 0x18 slave address + w transmitted. ack received. load smb0dat with data to be transmit- ted. 0x20 slave address + w transmitted. nack received. acknowledge poll to retry. set sto + sta. 0x28 data byte transmitted. ack received. 1) load smb0dat with next byte, or 2) set sto, or 3) clear sto then set sta for repeated start. 0x30 data byte transmitted. nack received. 1) retry transfer or 2) set sto. 0x38 arbitration lost. save current data. master receiver 0x40 slave address + r transmitted. ack received. if only receiving one byte, clear aa (send nack after received byte). wait for received data. 0x48 slave address + r transmitted. nack received. acknowledge poll to retry. set sto + sta. 0x50 data byte received. ack transmitted. read smb0dat. wait for next byte. if next byte is last byte, clear aa. 0x58 data byte received. nack transmitted. set sto.
page 234 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n slave receiver 0x60 own slave address + w received. ack trans- mitted. wait for data. 0x68 arbitration lost in sending sla + r/w as mas- ter. own address + w received. ack transmit- ted. save current data for retry when bus is free. wait for data. 0x70 general call address received. ack transmit- ted. wait for data. 0x78 arbitration lost in sending sla + r/w as mas- ter. general call address received. ack trans- mitted. save current data for retry when bus is free. 0x80 data byte received. ack transmitted. read smb0dat. wait for next byte or stop. 0x88 data byte received. nack transmitted. set sto to reset smbus. 0x90 data byte received after general call address. ack transmitted. read smb0dat. wait for next byte or stop. 0x98 data byte received after general call address. nack transmitted. setstotoresetsmbus. 0xa0 stop or repeated start received. no action necessary. slave transmitter 0xa8 own address + r received. ack transmitted. load smb0dat with data to transmit. 0xb0 arbitration lost in transmitting sla + r/w as master. own address + r received. ack transmitted. save current data for retry when bus is free. load smb0dat with data to trans- mit. 0xb8 data byte transmitted. ack received. load smb0dat with data to transmit. 0xc0 data byte transmitted. nack received. wait for stop. 0xc8 last data byte transmitted (aa=0). ack received. setstotoresetsmbus. slave 0xd0 scl clock high timer per smb0cr timed out set sto to reset smbus. all 0x00 bus error (illegal start or stop) set sto to reset smbus. 0xf8 idle state does not set si. table 19.1. smb0sta status codes and states mode status code smbus state typical action
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 235 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 20. enhanced serial peripheral interface (spi0) the enhanced serial peripheral interface (spi0) provides access to a flexible,full-duplex synchronous serial bus. spi0 can operate as a master or slave device in both 3-wire or 4-wire modes,and supports multiple masters and slaves on a single spi bus. the slave-select (nss) signal can be configured as an input to select spi0 in slave mode,or to disable master mode operation in a multi-master environment,avoiding contention on the spi bus when more than one master attempts simultaneous data transfers. nss can also be configured as a chip-select output in master mode, or disabled for 3-wire operation. additional general purpose port i/o pins can be used to select multiple slave devices in master mode. figure 20.1. spi block diagram sfr bus data path control sfr bus write spi0dat receivedatabuffer spi0dat 0 1 2 3 4 5 6 7 shift register spi control logic spi0ckr scr7 scr6 scr5 scr4 scr3 scr2 scr1 scr0 spi0cfg spi0cn pin interface control pin control logic c r o s s b a r port i/o read spi0dat spi irq txdata rxdata sck mosi miso nss transmit data buffer clock divide logic sysclk ckpha ckpol slvsel nssmd1 nssmd0 spibsy msten nssin srmt rxbmt spif wcol modf rxovrn txbmt spien
page 236 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 20.1. signal descriptions the four signals used by spi0 (mosi,miso,sck,nss) are described below. 20.1.1. master out, slave in (mosi) the master-out,slave-in (mosi) signal is an output from a master device and an input to slave devices. it is used to serially transfer data from the master to the slave. this signal is an output when spi0 is operating as a master and an input when spi0 is operating as a slave. data is transferred most-significant bit first. when configured as a master, mosi is driven by the msb of the shift register in both 3- and 4-wire mode. 20.1.2. master in, slave out (miso) the master-in,slave-out (miso) signal is an output from a slave device and an input to the master device. it is used to serially transfer data from the slave to the master. this signal is an input when spi0 is operating as a master and an output when spi0 is operating as a slave. data is transferred most-significant bit first. the miso pin is placed in a high-impedance state when the spi module is disabled and when the spi operates in 4-wire mode as a slave that is not selected. when acting as a slave in 3-wire mode,miso is always driven by the msb of the shift register. 20.1.3. serial clock (sck) the serial clock (sck) signal is an output from the master device and an input to slave devices. it is used to synchro- nize the transfer of data between the master and slave on the mosi and miso lines. spi0 generates this signal when operating as a master. the sck signal is ignored by a spi slave when the slave is not selected (nss = 1) in 4-wire slave mode. 20.1.4. slave select (nss) the function of the slave-select (nss) signal is dependent on the setting of the nssmd1 and nssmd0 bits in the spi0cn register. there are three possible modes that can be selected with these bits: 1. nssmd[1:0] = 00: 3-wire master or 3-wire slave mode: spi0 operates in 3-wire mode,and nss is disabled. when operating as a slave device,spi0 is always selected in 3-wire mode. since no select signal is present,spi0 must be the only slave on the bus in 3-wire mode. this is intended for point-to-point commu- nication between a master and one slave. 2. nssmd[1:0] = 01: 4-wire slave or multi-master mode: spi0 operates in 4-wire mode,and nss is enabled as an input. when operating as a slave,nss selects the spi0 device. when operating as a master,a 1-to-0 transition of the nss signal disables the master function of spi0 so that multiple master devices can be used on the same spi bus. 3. nssmd[1:0] = 1x: 4-wire master mode: spi0 operates in 4-wire mode,and nss is enabled as an out- put. the setting of nssmd0 determines what logic level the nss pin will output. this configuration should only be used when operating spi0 as a master device. see figure 20.2,figure 20.3,and figure 20.4 for typical connection diagrams of the various operational modes. note that the setting of nssmd bits affects the pinout of the device. when in 3-wire master or 3-wire slave mode,the nss pin will not be mapped by the crossbar. in all other modes,the nss signal will be mapped to a pin on the device. see section 17.1. ports 0 through 3 and the priority crossbar decoder onpage 193 for general purpose port i/ o and crossbar information.
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 237 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 20.2. spi0 master mode operation a spi master device initiates all data transfers on a spi bus. spi0 is placed in master mode by setting the master enable flag (msten,spi0cn.6). writing a byte of data to the spi0 data register (spi0dat) when in master mode writes to the transmit buffer. if the spi shift register is empty,the byte in the transmit buffer is moved to the shift reg- ister,and a data transfer begins. the spi0 master immediately shifts out the data serially on the mosi line while pro- viding the serial clock on sck. the spif (spi0cn.7) flag is set to logic 1 at the end of the transfer. if interrupts are enabled,an interrupt request is generated when the spif flag is set. while the spi0 master transfers data to a slave on the mosi line,the addressed spi slave device simultaneously transfers the contents of its shift register to the spi master on the miso line in a full-duplex operation. therefore,the spif flag serves as both a transmit-complete and receive-data-ready flag. the data byte received from the slave is transferred msb-first into the master's shift register. when a byte is fully shifted into the register,it is moved to the receive buffer where it can be read by the processor by reading spi0dat. when configured as a master,spi0 can operate in one of three different modes: multi-master mode,3-wire single- master mode,and 4-wire single-master mode. the default,multi-master mode is active when nssmd1 (spi0cn.3) = 0 and nssmd0 (spi0cn.2) = 1. in this mode,nss is an input to the device,and is used to disable the master spi0 when another master is accessing the bus. when nss is pulled low in this mode,msten (spi0cn.6) and spien (spi0cn.0) are set to 0 to disable the spi master device,and a mode fault is generated (modf,spi0cn.5 = 1). mode fault will generate an interrupt if enabled. spi0 must be manually re-enabled in software under these circum- stances. in multi-master systems,devices will typically default to being slave devices while they are not acting as the system master device. in multi-master mode,slave devices can be addressed individually (if needed) using general- purpose i/o pins. figure 20.2 shows a connection diagram between two master devices in multiple-master mode. 3-wire single-master mode is active when nssmd1 (spi0cn.3) = 0 and nssmd0 (spi0cn.2) = 0. in this mode, nss is not used,and is not mapped to an external port pin through the crossbar. any slave devices that must be addressed in this mode should be selected using general-purpose i/o pins. figure 20.3 shows a connection diagram between a master device in 3-wire master mode and a slave device. 4-wire single-master mode is active when nssmd1 (spi0cn.3) = 1. in this mode,nss is configured as an output pin,and can be used as a slave-select signal for a single spi device. in this mode,the output value of nss is con- trolled (in software) with the bit nssmd0 (spi0cn.2). additional slave devices can be addressed using general-pur- pose i/o pins. figure 20.4 shows a connection diagram for a master device in 4-wire master mode and two slave devices.
page 238 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n master device 2 master device 1 mosi miso sck miso mosi sck nss gpio nss gpio figure 20.2. multiple-master mode connection diagram figure 20.3. 3-wire single master and 3-wire single slave mode connection diagram slave device master device mosi miso sck miso mosi sck slave device master device mosi miso sck miso mosi sck nss nss gpio slave device mosi miso sck nss figure 20.4. 4-wire single master mode and 4-wire slave mode connection diagram
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 239 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 20.3. spi0 slave mode operation when spi0 is enabled and not configured as a master,it will operate as a spi slave. as a slave,bytes are shifted in through the mosi pin and out through the miso pin by a master device controlling the sck signal. a bit counter in the spi0 logic counts sck edges. when 8 bits have been shifted through the shift register,the spif flag is set to logic 1,and the byte is copied into the receive buffer. data is read from the receive buffer by reading spi0dat. a slave device cannot initiate transfers. data to be transferred to the master device is pre-loaded into the shift register by writ- ing to spi0dat. writes to spi0dat are double-buffered,and are placed in the transmit buffer first. if the shift regis- ter is empty,the contents of the transmit buffer will immediately be transferred into the shift register. when the shift register already contains data,the spi will wait until the byte is transferred before loading it with the transmit buffers contents. when configured as a slave,spi0 can be configured for 4-wire or 3-wire operation. the default,4-wire slave mode, is active when nssmd1 (spi0cn.3) = 0 and nssmd0 (spi0cn.2) = 1. in 4-wire mode,the nss signal is routed to a port pin and configured as a digital input. spi0 is enabled when nss is logic 0,and disabled when nss is logic 1. the bit counter is reset on a falling edge of nss. note that the nss signal must be driven low at least 2 system clocks before the first active edge of sck for each byte transfer. figure 20.4 shows a connection diagram between two slave devices in 4-wire slave mode and a master device. 3-wire slave mode is active when nssmd1 (spi0cn.3) = 0 and nssmd0 (spi0cn.2) = 0. nss is not used in this mode,and is not mapped to an external port pin through the crossbar. since there is no way of uniquely addressing the device in 3-wire slave mode,spi0 must be the only slave device present on the bus. it is important to note that in 3-wire slave mode there is no external means of resetting the bit counter that determines when a full byte has been received. the bit counter can only be reset by disabling and re-enabling spi0 with the spien bit. figure 20.3 shows a connection diagram between a slave device in 3-wire slave mode and a master device. 20.4. spi0 interrupt sources when spi0 interrupts are enabled,the following four flags will generate an interrupt when they are set to logic 1: note all of the following bits are cleared in software. 1. the spi interrupt flag,spif (spi0cn.7) is set to logic 1 at the end of each byte transfer. this flag can occur in all spi0 modes. 2. the write collision flag,wcol (spi0cn.6) is set to logic 1 if a write to spi0dat is attempted when the transmit buffer has not been emptied to the spi shift register. when this occurs,the write to spi0dat will be ignored,and the transmit buffer will not be written.this flag can occur in all spi0 modes. 3. the mode fault flag modf (spi0cn.5) is set to logic 1 when spi0 is configured as a master,and for multi-master mode and the nss pin is pulled low. when a mode fault occurs,the msten and spien bits in spi0cn are set to logic 0 to disable spi0 and allow another master device to access the bus. 4. the receive overrun flag rxovrn (spi0cn.4) is set to logic 1 when configured as a slave,and a transfer is completed and the receive buffer still holds an unread byte from a previous transfer. the new byte is not transferred to the receive buffer,allowing the previously received data byte to be read. the data byte which caused the overrun is lost.
page 240 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 20.5. serial clock timing as shown in figure 20.5,four combinations of serial clock phase and polarity can be selected using the clock control bits in the spi0 configuration register (spi0cfg). the ckpha bit (spi0cfg.5) selects one of two clock phases (edge used to latch the data). the ckpol bit (spi0cfg.4) selects between an active-high or active-low clock. both master and slave devices must be configured to use the same clock phase and polarity. note: spi0 should be disabled (by clearing the spien bit,spi0cn.0) when changing the clock phase or polarity. the spi0 clock rate register (spi0ckr) as shown in figure 20.8 controls the master mode serial clock frequency. this register is ignored when operating in slave mode. when the spi is configured as a master,the maximum data transfer rate (bits/sec) is one-half the system clock frequency. when the spi is configured as a slave,the maximum data transfer rate (bits/sec) for full-duplex operation is 1/10 the system clock frequency,provided that the master issues sck,nss (in 4-wire slave mode),and the serial input data synchronously with the system clock. if the master issues sck,nss,and the serial input data asynchronously,the maximum data transfer rate (bits/sec) must be less than 1/10 the system clock frequency. in the special case where the master only wants to transmit data to the slave and does not need to receive data from the slave (i.e. half-duplex operation),the spi slave can receive data at a maximum data transfer rate (bits/sec) of 1/4 the system clock frequency. this is provided that the master issues sck,nss,and the serial input data synchronously with the system clock. figure 20.5. data/clock timing diagram sck (ckpol=0, ckpha=0) sck (ckpol=0, ckpha=1) sck (ckpol=1, ckpha=0) sck (ckpol=1, ckpha=1) msb bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 miso/mosi nss
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 241 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 20.6. spi special function registers spi0 is accessed and controlled through four special function registers in the system controller: spi0cn control reg- ister,spi0dat data register,spi0cfg configuration register,and spi0ckr clock rate register. the four special function registers related to the operation of the spi0 bus are described in the following figures. figure 20.6. spi0cfg: spi0 configuration register bit 7: spibsy: spi busy (read only). this bit is set to logic 1 when a spi transfer is in progress (master or slave mode). bit6: msten:mastermodeenable. 0: disable master mode. operate in slave mode. 1: enable master mode. operate as a master. bit 5: ckpha: spi0 clock phase. this bit controls the spi0 clock phase. 0: data centered on first edge of sck period. ? 1: data centered on second edge of sck period. ? bit 4: ckpol: spi0 clock polarity. this bit controls the spi0 clock polarity. 0: sck line low in idle state. 1: sck line high in idle state. bit 3: slvsel: slave selected flag (read only). this bit is set to logic 1 whenever the nss pin is low indicating spi0 is the selected slave. it is cleared to logic 0 when nss is high (slave not selected). this bit does not indicate the instantaneous value at the nss pin,but rather a de-glitched version of the pin input. bit 2: nssin: nss instantaneous pin input (read only). this bit mimics the instantaneous value that is present on the nss port pin at the time that the register is read. this input is not de-glitched. bit 1: srmt: shift register empty (valid in slave mode,read only). this bit will be set to logic 1 when all data has been transferred in/out of the shift register,and there is no new information available to read from the transmit buffer or write to the receive buffer. it returns to logic 0 when a data byte is transferred to the shift register from the transmit buffer or by a transition on sck. note: srmt = 1 when in master mode. bit 0: rxbmt: receive buffer empty (valid in slave mode,read only). this bit will be set to logic 1 when the receive buffer has been read and contains no new information. if there is new information available in the receive buffer that has not been read,this bit will return to logic 0. note:rxbmt=1wheninmastermode. ? in slave mode,data on mosi is sampled in the center of each data bit. in master mode,data on miso is sampled one sysclk before the end of each data bit,to provide maximum settling time for the slave device. see table 20.1 for timing parameters. rr/wr/wr/wrrrrresetvalue spibsy msten ckpha ckpol slvsel nssin srmt rxbmt 00000111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x9a 0
page 242 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 20.7. spi0cn: spi0 control register bit 7: spif: spi0 interrupt flag. this bit is set to logic 1 by hardware at the end of a data transfer. if interrupts are enabled,setting this bit causes the cpu to vector to the spi0 interrupt service routine. this bit is not automatically cleared by hardware. it must be cleared by software. bit 6: wcol: write collision flag. this bit is set to logic 1 by hardware (and generates a spi0 interrupt) to indicate a write to the spi0 data register was attempted while a data transfer was in progress. it must be cleared by software. bit5: modf:modefaultflag. this bit is set to logic 1 by hardware (and generates a spi0 interrupt) when a master mode collision is detected (nss is low,msten = 1,and nssmd[1:0] = 01). this bit is not automatically cleared by hardware. it must be cleared by software. bit 4: rxovrn: receive overrun flag (slave mode only). this bit is set to logic 1 by hardware (and generates a spi0 interrupt) when the receive buffer still holds unread data from a previous transfer and the last bit of the current transfer is shifted into the spi0 shift register. this bit is not automatically cleared by hardware. it must be cleared by software. bits 3-2: nssmd1-nssmd0: slave select mode. selects between the following nss operation modes: (see section 20.2. spi0 master mode operation on page 237 and section 20.3. spi0 slave mode operation on page 239 ). 00: 3-wire slave or 3-wire master mode. nss signal is not routed to a port pin. 01: 4-wire slave or multi-master mode (default). nss is always an input to the device. 1x: 4-wire single-master mode. nss signal is mapped as an output from the device and will assume the value of nssmd0. bit1: txbmt:transmitbufferempty. this bit will be set to logic 0 when new data has been written to the transmit buffer. when data in the transmit buffer is transferred to the spi shift register,this bit will be set to logic 1,indicating that it is safe to write a new byte to the transmit buffer. bit0: spien:spi0enable. this bit enables/disables the spi. 0: spi disabled. 1: spi enabled. r/wr/wr/wr/wr/wr/w r r/wresetvalue spif wcol modf rxovrn nssmd1 nssmd0 txbmt spien 00000110 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xf8 0
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 243 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 20.8. spi0ckr: spi0 clock rate register bits 7-0: scr7-scr0: spi0 clock rate. these bits determine the frequency of the sck output when the spi0 module is configured for master mode operation. the sck clock frequency is a divided version of the system clock,and is given in the following equation,where sysclk is the system clock frequency and spi0ckr is the 8-bit value held in the spi0ckr register. for 0 <= spi0ckr <= 255 example: if sysclk = 2 mhz and spi0ckr = 0x04, r/wr/wr/wr/wr/wr/wr/wr/wresetvalue scr7 scr6 scr5 scr4 scr3 scr2 scr1 scr0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x9d 0 f sck 2000000 241 + () -------------------------- = f sck 200 khz = f sck sysclk 2 spi 0 ckr 1 + () ------------------------------------------------ - =
page 244 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 20.9. spi0dat: spi0 data register bits 7-0: spi0dat: spi0 transmit and receive data. the spi0dat register is used to transmit and receive spi0 data. writing data to spi0dat places the data into the transmit buffer and initiates a transfer when in master mode. a read of spi0dat returns the contents of the receive buffer. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x9b 0
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 245 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information sck* t se nss t ckh t ckl mosi t sis t sih miso t sd t soh * sck is shown for ckpol = 0. sck is the opposite polarity for ckpol = 1. figure 20.10. spi slave timing (ckpha = 0) sck* t se nss t ckh t ckl mosi t sis t sih miso t sd t soh * sck is shown for ckpol = 0. sck is the opposite polarity for ckpol = 1. figure 20.11. spi slave timing (ckpha = 1)
page 246 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n sck* t mckh t mckl mosi t mis miso * sck is shown for ckpol = 0. sck is the opposite polarity for ckpol = 1. t mih figure 20.12. spi master timing (ckpha = 0) sck* t mckh t mckl miso t mih mosi * sck is shown for ckpol = 0. sck is the opposite polarity for ckpol = 1. t mis figure 20.13. spi master timing (ckpha = 1)
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 247 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information table 20.1. spi slave timing parameters parameter descriptionminmax units t sysclk system clock period 40 ns slavemodetiming ? t se nss falling to first sck edge (slave enable) 2*t sysclk ns t sd last sck edge to nss rising (slave disable) 2*t sysclk ns t ckh sck high time 5*t sysclk ns t ckl sck low time 5*t sysclk ns t sis mosi valid to sck sample edge (mosi setup) 2*t sysclk ns t sih sck sample edge to mosi change (mosi hold) 2*t sysclk ns t soh sck shift edge to miso change (miso hold) 4*t sysclk ns master mode timing ?? t mckh sck high time 1*t sysclk ns t mckl sck low time 1*t sysclk ns t mis miso valid to sck shift edge (mosi setup) 1*t sysclk +20 ns t mih sck shift edge to miso change (miso hold) 0 ns ? see figure 20.10 and figure 20.11 for slave mode timing diagrams. ?? see figure 20.12 and figure 20.13 for master mode timing diagrams.
page 248 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n notes
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 249 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 21. uart0 uart0 is an enhanced serial port with frame error detection and address recognition hardware. uart0 may operate in full-duplex asynchronous or half-duplex synchronous modes,and mutiproccessor communication is fully sup- ported. receive data is buffered in a holding register,allowing uart0 to start reception of a second incoming data byte before software has finished reading the previous data byte. a receive overrun bit indicates when new received data is latched into the receive buffer before the previously received byte has been read. uart0 is accessed via its associated sfrs,serial control (scon0) and serial data buffer (sbuf0). the single sbuf0 location provides access to both transmit and receive registers. reading scon0 accesses the receive register and writing scon0 accesses the transmit register. uart0 may be operated in polled or interrupt mode. uart0 has two sources of interrupts: a transmit interrupt flag, ti0 (scon0.1) set when transmission of a data byte is complete,and a receive interrupt flag,ri0 (scon0.0) set when reception of a data byte is complete. uart0 interrupt flags are not cleared by hardware when the cpu vectors to the interrupt service routine; they must be cleared manually by software. this allows software to determine the cause of the uart0 interrupt (transmit complete or receive complete). figure 21.1. uart0 block diagram tx control txclock txirq zero detector send shift set q d clr stop bit gen. tb80 start data write to sbuf0 crossbar tx0 port i/o serial port (uart0) interrupt rx control start rxclock load sbuf 0x1ff shift en rxirq uart0 baud rate generation logic sfr bus input shift register (9 bits) frame error detection sbuf0 read sbuf0 sfr bus saddr0 saden0 match detect rb80 load sbuf0 crossbar rx0 sbuf0 address match scon0 s m 2 0 t b 8 0 r b 8 0 t i 0 r i 0 s m 1 0 s m 0 0 r e n 0 ssta0 t x c o l 0 s 0 t c l k 1 s 0 t c l k 1 s 0 r c l k 1 s 0 r c l k 1 r x o v 0 f e 0 s m o d 0 ti0 ri0
page 250 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 21.1. uart0 operational modes uart0 provides four operating modes (one synchronous and three asynchronous) selected by setting configuration bits in the scon0 register. these four modes offer different baud rates and communication protocols. the four modes are summarized in table 21.1. 21.1.1. mode 0: synchronous mode mode 0 provides synchronous,half-duplex communication. serial data is transmitted and received on the rx0 pin. the tx0 pin provides the shift clock for both transmit and receive. the mcu must be the master since it generates the shift clock for transmission in both directions (see the interconnect diagram in figure 21.3). data transmission begins when an instruction writes a data byte to the sbuf0 register. eight data bits are transferred lsb first (see the timing diagram in figure 21.2),and the ti0 transmit interrupt flag (scon0.1) is set at the end of the eighth bit time. data reception begins when the ren0 receive enable bit (scon0.4) is set to logic 1 and the ri0 receive interrupt flag (scon0.0) is cleared. one cycle after the eighth bit is shifted in,the ri0 flag is set and recep- tion stops until software clears the ri0 bit. an interrupt will occur if enabled when either ti0 or ri0 are set. the mode 0 baud rate is sysclk / 12. rx0 is forced to open-drain in mode 0,and an external pull-up will typically be required. table 21.1. uart0 modes mode synchronization baud clock data bits start/stop bits 0 synchronous sysclk / 12 8 none 1 asynchronous timer 1,2,3,or 4 overflow 8 1 start,1 stop 2 asynchronous sysclk / 32 or sysclk / 64 9 1 start,1 stop 3 asynchronous timer 1,2,3,or 4 overflow 9 1 start,1 stop figure 21.2. uart0 mode 0 timing diagram d1 d0 d2 d3 d4 d5 d6 d7 rx (data out) mode 0 transmit d0 mode 0 receive rx (data in) d1 d2 d3 d4 d5 d6 d7 tx (clk out) tx (clk out) figure 21.3. uart0 mode 0 interconnect shift reg. clk c8051fxxx rx tx data 8 extra outputs
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 251 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 21.1.2. mode 1: 8-bit uart, variable baud rate mode 1 provides standard asynchronous,full duplex communication using a total of 10 bits per data byte: one start bit,eight data bits (lsb first),and one stop bit. data are transmitted from the tx0 pin and received at the rx0 pin. on receive,the eight data bits are stored in sbuf0 and the stop bit goes into rb80 (scon0.2). data transmission begins when an instruction writes a data byte to the sbuf0 register. the ti0 transmit interrupt flag (scon0.1) is set at the end of the transmission (the beginning of the stop-bit time). data reception can begin any time after the ren0 receive enable bit (scon0.4) is set to logic 1. after the stop bit is received,the data byte will be loaded into the sbuf0 receive register if the following conditions are met: ri0 must be logic 0,and if sm20 is logic 1,the stop bit must be logic 1. if these conditions are met,the eight bits of data is stored in sbuf0,the stop bit is stored in rb80 and the ri0 flag is set. if these conditions are not met,sbuf0 and rb80 will not be loaded and the ri0 flag will not be set. an interrupt will occur if enabled when either ti0 or ri0 are set. the baud rate generated in mode 1 is a function of timer overflow,shown in equation 21.1 and equation 21.2. uart0 can use timer 1 operating in 8-bit auto-reload mode ,or timer 2,3,or 4 operating in auto-reload mode to generate the baud rate (note that the tx and rx clocks are selected separately). on each timer overflow event (a roll- over from all ones - (0xff for timer 1,0xffff for timer 2) - to zero) a clock is sent to the baud rate logic. timers 1,2,3,and 4 are selected as the baud rate source with bits in the ssta0 register (see figure 21.9). the trans- mit baud rate clock is selected using the s0tclk1 and s0tclk0 bits,and the receive baud rate clock is selected using the s0rclk1 and s0rclk0 bits. the mode 1 baud rate equations are shown below,where t1m is bit4 of register ckcon,th1 is the 8-bit reload reg- ister for timer 1,and [rcapnh ,rcapnl] is the 16-bit reload register for timer 2,3,or 4. figure 21.4. uart0 mode 1 timing diagram d1 d0 d2 d3 d4 d5 d6 d7 start bit mark stop bit bit times bit sampling space equation 21.1. mode 1 baud rate using timer 1 baudrate 2 smod 0 32 ------------------ - ?? ?? sysclk 12 t 1 m 1 ) C () 256 th 1 C () -------------------------------------------------------- ?? ?? = equation 21.2. mode 1 baud rate using timer 2, 3, or 4 baudrate sysclk 16 65536 rcapnh rcapnl [,] C () -------------------------------------------------------------------------------------------- - =
page 252 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 21.1.3. mode 2: 9-bit uart, fixed baud rate mode 2 provides asynchronous,full-duplex communication using a total of eleven bits per data byte: a start bit,8 data bits (lsb first),a programmable ninth data bit,and a stop bit. mode 2 supports multiprocessor communications and hardware address recognition (see section 21.2 ). on transmit,the ninth data bit is determined by the value in tb80 (scon0.3). it can be assigned the value of the parity flag p in the psw or used in multiprocessor communications. on receive,the ninth data bit goes into rb80 (scon0.2) and the stop bit is ignored. data transmission begins when an instruction writes a data byte to the sbuf0 register. the ti0 transmit interrupt flag (scon0.1) is set at the end of the transmission (the beginning of the stop-bit time). data reception can begin any time after the ren0 receive enable bit (scon0.4) is set to logic 1. after the stop bit is received,the data byte will be loaded into the sbuf0 receive register if ri0 is logic 0 and one of the following requirements are met: 1. sm20 is logic 0 2. sm20 is logic 1,the received 9th bit is logic 1,and the received address matches the uart0 address as described in section 21.2 . if the above conditions are satisfied,the eight bits of data are stored in sbuf0,the ninth bit is stored in rb80 and the ri0 flag is set. if these conditions are not met,sbuf0 and rb80 will not be loaded and the ri0 flag will not be set. an interrupt will occur if enabled when either ti0 or ri0 are set. the baud rate in mode 2 is either sysclk / 32 or sysclk / 64,according to the value of the smod0 bit in register ssta0. equation 21.3. mode 2 baud rate baudrate 2 smod 0 sysclk 64 --------------------- - ?? ?? = figure 21.5. uart0 modes 2 and 3 timing diagram d1 d0 d2 d3 d4 d5 d6 d7 start bit mark stop bit bit times bit sampling space d8
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 253 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 21.1.4. mode 3: 9-bit uart, variable baud rate mode3usesthemode2transmissionprotocolwiththemode1baudrategeneration.mode3operationtransmits11 bits: a start bit,8 data bits (lsb first),a programmable ninth data bit,and a stop bit. the baud rate is derived from timer 1 or timer 2,3,or 4 overflows,as defined by equation 21.1 and equation 21.2. multiprocessor communica- tions and hardware address recognition are supported,as described in section 21.2 . f i gure 21 . 6 .uart 0 modes 1 , 2 ,and 3 interconnect d i agram or rs-232 c8051fxxx rs-232 level xltr tx rx c8051fxxx rx tx mcu rx tx
page 254 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 21.2. multiprocessor communications modes 2 and 3 support multiprocessor communication between a master processor and one or more slave processors by special use of the ninth data bit and the built-in uart0 address recognition hardware. when a master processor wants to transmit to one or more slaves,it first sends an address byte to select the target(s). an address byte differs from a data byte in that its ninth bit is logic 1; in a data byte,the ninth bit is always set to logic 0. uart0 will recog- nize as valid (i.e.,capable of causing an interrupt) two types of addresses: (1) a masked address and (2) a broadcast address at any given time . both are described below. 21.2.1. configuration of a masked address the uart0 address is configured via two sfrs: saddr0 (serial address) and saden0 (serial address enable). saden0 sets the bit mask for the address held in saddr0: bits set to logic 1 in saden0 correspond to bits in saddr0 that are checked against the received address byte; bits set to logic 0 in saden0 correspond to dont care bits in saddr0. setting the sm20 bit (scon0.5) configures uart0 such that when a stop bit is received,uart0 will generate an interrupt only if the ninth bit is logic 1 (rb80 = 1) and the received data byte matches the uart0 slave address. following the received address interrupt,the slave will clear its sm20 bit to enable interrupts on the reception of the following data byte(s). once the entire message is received,the addressed slave resets its sm20 bit to ignore all trans- missions until it receives the next address byte. while sm20 is logic 1,uart0 ignores all bytes that do not match the uart0 address and include a ninth bit that is logic 1. 21.2.2. broadcast addressing multiple addresses can be assigned to a single slave and/or a single address can be assigned to multiple slaves, thereby enabling "broadcast" transmissions to more than one slave simultaneously. the broadcast address is the logi- cal or of registers saddr0 and saden0,and 0s of the result are treated as dont cares. typically a broadcast address of 0xff (hexadecimal) is acknowledged by all slaves,assuming dont care bits as 1s. the master proces- sor can be configured to receive all transmissions or a protocol can be implemented such that the master/slave role is temporarily reversed to enable half-duplex transmission between the original master and slave(s).. note in the above examples 4,5,and 6,each slave would recognize as valid an address of 0xff as a broadcast address. also note that examples 4,5,and 6 uses the same saddr0 and saden0 register values as shown in the examples 1,2,and 3 respectively (slaves #1,2,and 3). thus,a master could address each slave device individually using a masked address,and also broadcast to all three slave devices. for example,if a master were to send an address 11110101,only slave #1 would recognize the address as valid. if a master were to then send an address of 11111111,all three slave devices would recognize the address as a valid broadcast address. example 1, slave #1 example 2, slave #2 example 3, slave #3 saddr0 = 00110101 saddr0 = 00110101 saddr0 = 00110101 saden0 = 00001111 saden0 = 11110011 saden0 = 11000000 uart0 address = xxxx0101 uart0 address = 0011xx01 uart0 address = 00xxxxxx example 4, slave #1 example 5, slave #2 example 6, slave #3 saddr0 = 00110101 saddr0 = 00110101 saddr0 = 00110101 saden0 = 00001111 saden0 = 11110011 saden0 = 11000000 broadcast address = 00111111 broadcast address = 11110111 broadcast address = 11110101 where all zeroes in the broadcast address are dont cares.
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 255 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 21.3. frame and transmission error detection all modes: the transmit collision bit (txcol0 bit in register scon0) reads 1 if user software writes data to the sbuf0 reg- ister while a transmit is in progress. note that the txcol0 bit is also used as the sm20 bit when written by user soft- ware. this bit does not generate an interrupt. modes1,2,and3: the receive overrun bit (rxov0 in register scon0) reads 1 if a new data byte is latched into the receive buffer before software has read the previous byte. note that the rxov0 bit is also used as the sm10 bit when written by user software. the frame error bit (fe0 in register scon0) reads 1 if an invalid (low) stop bit is detected. note that the fe0 bit is also used as the sm00 bit when written by user software. the rxov0 and fe0 bits do not generate interrupts. figure 21.7. uart multi-processor mode interconnect diagram master device slave device tx rx rx tx slave device rx tx slave device rx tx +5v
page 256 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n table 21.2. oscillator frequencies for standard baud rates oscillator frequency (mhz) divide factor timer 1 reload value* timer2,3,or4 reload value resulting baud rate (hz)** 24.0 208 0xf3 0xfff3 115200 (115384) 22.1184 192 0xf4 0xfff4 115200 18.432 160 0xf6 0xfff6 115200 11.0592 96 0xfa 0xfffa 115200 3.6864 32 0xfe 0xfffe 115200 1.8432 16 0xff 0xffff 115200 24.0 832 0xcc 0xffcc 28800 (28846) 22.1184 768 0xd0 0xffd0 28800 18.432 640 0xd8 0xffd8 28800 11.0592 348 0xe8 0xffe8 28800 3.6864 128 0xf8 0xfff8 28800 1.8432 64 0xfc 0xfffc 28800 24.0 2496 0x64 0xff64 9600 (9615) 22.1184 2304 0x70 0xff70 9600 18.432 1920 0x88 0xff88 9600 11.0592 1152 0xb8 0xffb8 9600 3.6864 384 0xe8 0xffe8 9600 1.8432 192 0xf4 0xfff4 9600 * assumes smod0=1 and t1m=1. ** numbers in parenthesis show the actual baud rate.
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 257 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 21.8. scon0: uart0 control register bits7-6: sm00-sm10: serial port operation mode: write: when written,these bits select the serial port operation mode as follows: reading these bits returns the current uart0 mode as defined above. bit5: sm20: multiprocessor communication enable. the function of this bit is dependent on the serial port operation mode. mode 0: no effect. mode 1: checks for valid stop bit. 0: logic level of stop bit is ignored. 1: ri0 will only be activated if stop bit is logic level 1. mode 2 and 3: multiprocessor communications enable. 0: logic level of ninth bit is ignored. 1: ri0 is set and an interrupt is generated only when the ninth bit is logic 1 and the received address matches the uart0 address or the broadcast address. bit4: ren0: receive enable. this bit enables/disables the uart0 receiver. 0: uart0 reception disabled. 1: uart0 reception enabled. bit3: tb80: ninth transmission bit. the logic level of this bit will be assigned to the ninth transmission bit in modes 2 and 3. it is not used in modes 0 and 1. set or cleared by software as required. bit2: rb80: ninth receive bit. the bit is assigned the logic level of the ninth bit received in modes 2 and 3. in mode 1,if sm20 is logic 0,rb80 is assigned the logic level of the received stop bit. rb8 is not used in mode 0. bit1: ti0:transmitinterruptflag. set by hardware when a byte of data has been transmitted by uart0 (after the 8th bit in mode 0,or at the beginning of the stop bit in other modes). when the uart0 interrupt is enabled,setting this bit causes the cpu to vector to the uart0 interrupt service routine. this bit must be cleared manually by software. bit0: ri0: receive interrupt flag. set by hardware when a byte of data has been received by uart0 (as selected by the sm20 bit). when the uart0 interrupt is enabled,setting this bit causes the cpu to vector to the uart0 inter- rupt service routine. this bit must be cleared manually by software. r/w r/w r/w r/w r/w r/w r/w r/w reset value sm00 sm10 sm20 ren0 tb80 rb80 ti0 ri0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0x98 0 sm00 sm10 mode 0 0 mode 0: synchronous mode 0 1 mode 1: 8-bit uart,variable baud rate 1 0 mode 2: 9-bit uart,fixed baud rate 1 1 mode 3: 9-bit uart,variable baud rate
page 258 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 21.9. ssta0: uart0 status and clock selection register bit7: fe0: frame error flag. ? this flag indicates if an invalid (low) stop bit is detected. 0: frame error has not been detected. 1: frame error has been detected. bit6: rxov0: receive overrun flag. ? this flag indicates new data has been latched into the receive buffer before software has read the pre- vious byte. 0: receive overrun has not been detected. 1: receive overrun has been detected. bit5: txcol0: transmit collision flag. ? this flag indicates user software has written to the sbuf0 register while a transmission is in progress. 0: transmission collision has not been detected. 1: transmission collision has been detected. bit4: smod0: uart0 baud rate doubler enable. this bit enables/disables the divide-by-two function of the uart0 baud rate logic for configurations described in the uart0 section. 0: uart0 baud rate divide-by-two enabled. 1: uart0 baud rate divide-by-two disabled. bits3-2: uart0 transmit baud rate clock selection bits. bits1-0: uart0 receive baud rate clock selection bits. ? note: fe0,rxov0,and txcol0 are flags only,and no interrupt is generated by these conditions. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue fe0 rxov0 txcol0 smod0 s0tclk1 s0tclk0 s0rclk1 s0rclk0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x91 0 s0tclk1 s0tclk0 serial transmit baud rate clock source 0 0 timer 1 generates uart0 tx baud rate 0 1 timer 2 overflow generates uart0 tx baud rate 1 0 timer 3 overflow generates uart0 tx baud rate 1 1 timer 4 overflow generates uart0 tx baud rate s0rclk1 s0rclk0 serial receive baud rate clock source 0 0 timer 1 generates uart0 rx baud rate 0 1 timer 2 overflow generates uart0 rx baud rate 1 0 timer 3 overflow generates uart0 rx baud rate 1 1 timer 4 overflow generates uart0 rx baud rate
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 259 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 21.10. sbuf0: uart0 data buffer register bits7-0: sbuf0.[7:0]: uart0 buffer bits 7-0 (msb-lsb). this is actually two registers; a transmit and a receive buffer register. when data is moved to sbuf0, it goes to the transmit buffer and is held for serial transmission. moving a byte to sbuf0 is what ini- tiates the transmission. when data is moved from sbuf0,it comes from the receive buffer. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x99 0 figure 21.11. saddr0: uart0 slave address register bits7-0: saddr0.[7:0]: uart0 slave address. the contents of this register are used to define the uart0 slave address. register saden0 is a bit mask to determine which bits of saddr0 are checked against a received address: corresponding bits set to logic 1 in saden0 are checked; corresponding bits set to logic 0 are dont cares. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xa9 0 figure 21.12. saden0: uart0 slave address enable register bits7-0: saden0.[7:0]: uart0 slave address enable. bits in this register enable corresponding bits in register saddr0 to determine the uart0 slave address. 0: corresponding bit in saddr0 is a dont care. 1: corresponding bit in saddr0 is checked against a received address. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xb9 0
page 260 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n notes
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 261 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 22. uart1 uart1 is an asynchronous,full duplex serial port offering modes 1 and 3 of the standard 8051 uart. enhanced baud rate support allows a wide range of clock sources to generate standard baud rates (details in section 22.1. enhanced baud rate generation on page 262 ). received data buffering allows uart1 to start reception of a second incoming data byte before software has finished reading the previous data byte. uart1 has two associated sfrs: serial control register 1 (scon1) and serial data buffer 1 (sbuf1). the single sbuf1 location provides access to both transmit and receive registers. reading sbuf1 accesses the buffered receive register; writing sbuf1 accesses the transmit register. with uart1 interrupts enabled,an interrupt is generated each time a transmit is completed (ti1 is set in scon1),or a data byte has been received (ri1 is set in scon1). the uart1 interrupt flags are not cleared by hardware when the cpu vectors to the interrupt service routine. they must be cleared manually by software,allowing software to determine the cause of the uart1 interrupt (transmit complete or receive complete). figure 22.1. uart1 block diagram uart1 baud rate generator ri1 scon1 ri1 ti1 rb81 tb81 ren1 mce1 s1mode txcontrol txclock send sbuf1 (tx shift) start data write to sbuf1 crossbar tx1 shift zero detector txirq set q d clr stop bit tb81 sfr bus serial port interrupt ti1 port i/o rxcontrol start rxclock load sbuf1 shift 0x1ff rb81 rxirq input shift register (9 bits) load sbuf1 read sbuf1 sfr bus crossbar rx1 sbuf1 (rx latch)
page 262 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 22.1. enhanced baud rate generation the uart1 baud rate is generated by timer 1 in 8-bit auto-reload mode. the tx clock is generated by tl1; the rx clock is generated by a copy of tl1 (shown as rx timer in figure 22.2),which is not user-accessible. both tx and rx timer overflows are divided by two to generate the tx and rx baud rates. the rx timer runs when timer 1 is enabled,and uses the same reload value (th1). however,an rx timer reload is forced when a start condition is detected on the rx pin. this allows a receive to begin any time a start is detected,independent of the tx timer state. timer 1 should be configured for mode 2,8-bit auto-reload (see section 23.1.3. mode 2: 8-bit counter/timer with auto-reload on page 273 ). the timer 1 reload value should be set so that overflows will occur at two times the desired baud rate. note that timer 1 may be clocked by one of five sources: sysclk,sysclk / 4,sysclk / 12,sysclk / 48,or the external oscillator clock / 8. for any given timer 1 clock source,the uart1 baud rate is determined by equation 22.1. where t1 clk is the frequency of the clock supplied to timer 1,and t1h is the high byte of timer 1 (reload value). timer 1 clock frequency is selected as described in section 23.1. timer 0 and timer 1 on page 271 .aquickref- erence for typical baud rates and system clock frequencies is given in table 22.1 through table 22.6. note that the internal oscillator may still generate the system clock when the external oscillator is driving timer 1 (see section 23.1. timer 0 and timer 1 on page 271 for more details). figure 22.2. uart1 baud rate logic rx timer start detected overflow overflow th1 tl1 tx clock 2 rx clock 2 timer 1 uart1 equation 22.1. uart1 baud rate uartbaudrate t 1 clk 256 t 1 h C () ------------------------------ - 1 2 -- - =
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 263 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 22.2. operational modes uart1 provides standard asynchronous,full duplex communication. the uart mode (8-bit or 9-bit) is selected by the s1mode bit (scon1.7). typical uart connection options are shown below. 22.2.1. 8-bit uart 8-bit uart mode uses a total of 10 bits per data byte: one start bit,eight data bits (lsb first),and one stop bit. data are transmitted lsb first from the tx1 pin and received at the rx1 pin. on receive,the eight data bits are stored in sbuf1 and the stop bit goes into rb81 (scon1.2). data transmission begins when software writes a data byte to the sbuf1 register. the ti1 transmit interrupt flag (scon1.1) is set at the end of the transmission (the beginning of the stop-bit time). data reception can begin any time after the ren1 receive enable bit (scon1.4) is set to logic 1. after the stop bit is received,the data byte will be loaded into the sbuf1 receive register if the following conditions are met: ri1 must be logic 0,and if mce1 is logic 1,the stop bit must be logic 1. in the event of a receive data overrun,the first received 8 bits are latched into the sbuf1 receive register and the following overrun data bits are lost. if these conditions are met,the eight bits of data is stored in sbuf1,the stop bit is stored in rb81 and the ri1 flag is set. if these conditions are not met,sbuf1 and rb81 will not be loaded and the ri1 flag will not be set. an interrupt will occur if enabled when either ti1 or ri1 is set. figure 22.3. uart interconnect diagram or rs-232 c8051fxxx rs-232 level xltr tx rx c8051fxxx rx tx mcu rx tx figure 22.4. 8-bit uart timing diagram d1 d0 d2 d3 d4 d5 d6 d7 start bit mark stop bit bit times bit sampling space
page 264 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 22.2.2. 9-bit uart 9-bit uart mode uses a total of eleven bits per data byte: a start bit,8 data bits (lsb first),a programmable ninth data bit,and a stop bit. the state of the ninth transmit data bit is determined by the value in tb81 (scon1.3),which is assigned by user software. it can be assigned the value of the parity flag (bit p in register psw) for error detection, or used in multiprocessor communications. on receive,the ninth data bit goes into rb81 (scon1.2) and the stop bit is ignored. data transmission begins when an instruction writes a data byte to the sbuf1 register. the ti1 transmit interrupt flag (scon1.1) is set at the end of the transmission (the beginning of the stop-bit time). data reception can begin any time after the ren1 receive enable bit (scon1.4) is set to 1. after the stop bit is received,the data byte will be loaded into the sbuf1 receive register if the following conditions are met: (1) ri1 must be logic 0,and (2) if mce1 is logic 1,the 9th bit must be logic 1 (when mce1 is logic 0,the state of the ninth data bit is unimportant). if these conditions are met,the eight bits of data are stored in sbuf1,the ninth bit is stored in rb81,and the ri1 flag is set to 1. if the above conditions are not met,sbuf1 and rb81 will not be loaded and the ri1 flag will not be set to 1. a uart1 interrupt will occur if enabled when either ti1 or ri1 is set to 1. figure 22.5. 9-bit uart timing diagram d1 d0 d2 d3 d4 d5 d6 d7 start bit mark stop bit bit times bit sampling space d8
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 265 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 22.3. multiprocessor communications 9-bit uart mode supports multiprocessor communication between a master processor and one or more slave pro- cessors by special use of the ninth data bit. when a master processor wants to transmit to one or more slaves,it first sends an address byte to select the target(s). an address byte differs from a data byte in that its ninth bit is logic 1; in a data byte,the ninth bit is always set to logic 0. setting the mce1 bit (scon.5) of a slave processor configures its uart such that when a stop bit is received,the uart will generate an interrupt only if the ninth bit is logic one (rb81 = 1) signifying an address byte has been received. in the uart interrupt handler,software should compare the received address with the slave's own assigned 8-bit address. if the addresses match,the slave should clear its mce1 bit to enable interrupts on the reception of the following data byte(s). slaves that weren't addressed leave their mce1 bits set and do not generate interrupts on the reception of the following data bytes,thereby ignoring the data. once the entire message is received,the addressed slave should reset its mce1 bit to ignore all transmissions until it receives the next address byte. multiple addresses can be assigned to a single slave and/or a single address can be assigned to multiple slaves, thereby enabling "broadcast" transmissions to more than one slave simultaneously. the master processor can be con- figured to receive all transmissions or a protocol can be implemented such that the master/slave role is temporarily reversed to enable half-duplex transmission between the original master and slave(s). figure 22.6. uart multi-processor mode interconnect diagram master device slave device tx rx rx tx slave device rx tx slave device rx tx +5v
page 266 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 22.7. scon1: serial port 1 control register bit7: s1mode: serial port 1 operation mode. this bit selects the uart1 operation mode. 0: 8-bit uart with variable baud rate. 1: 9-bit uart with variable baud rate. bit6: unused. read = 1b. write = dont care. bit5: mce1: multiprocessor communication enable. the function of this bit is dependent on the serial port 0 operation mode. s1mode = 0: checks for valid stop bit. 0: logic level of stop bit is ignored. 1: ri1 will only be activated if stop bit is logic level 1. s1mode = 1: multiprocessor communications enable. 0: logic level of ninth bit is ignored. 1:ri1issetandaninterruptisgeneratedonlywhentheninthbitislogic1. bit4: ren1: receive enable. this bit enables/disables the uart receiver. 0: uart1 reception disabled. 1: uart1 reception enabled. bit3: tb81: ninth transmission bit. the logic level of this bit will be assigned to the ninth transmission bit in 9-bit uart mode. it is not used in 8-bit uart mode. set or cleared by software as required. bit2: rb81: ninth receive bit. rb81 is assigned the value of the stop bit in mode 0; it is assigned the value of the 9th data bit in mode 1. bit1: ti1:transmitinterruptflag. set by hardware when a byte of data has been transmitted by uart1 (after the 8th bit in 8-bit uart mode,or at the beginning of the stop bit in 9-bit uart mode). when the uart1 interrupt is enabled,setting this bit causes the cpu to vector to the uart1 interrupt service routine. this bit must be cleared manually by software. bit0: ri1: receive interrupt flag. set to 1 by hardware when a byte of data has been received by uart1 (set at the stop bit sam- pling time). when the uart1 interrupt is enabled,setting this bit to 1 causes the cpu to vector to the uart1 interrupt service routine. this bit must be cleared manually by software. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue s1mode - mce1 ren1 tb81 rb81 ti1 ri1 01000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0x98 1
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 267 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 22.8. sbuf1: serial (uart1) port data buffer register bits7-0: sbuf1[7:0]: serial data buffer bits 7-0 (msb-lsb). this sfr accesses two registers; a transmit shift register and a receive latch register. when data is written to sbuf1,it goes to the transmit shift register and is held for serial transmission. writing a byte to sbuf1 is what initiates the transmission. a read of sbuf1 returns the contents of the receive latch. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x99 1
page 268 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n table 22.1. timer settings for standard baud rates using the internal oscillator frequency: 24.5 mhz target baud rate (bps) baud rate %error oscillator divide factor timer clock source sca1-sca0 (pre-scale select) ? t1m ? timer 1 reload va lu e (h ex) sysclk from internal osc. 230400 -0.32% 106 sysclk xx 1 0xcb 115200 -0.32% 212 sysclk xx 1 0x96 57600 0.15% 426 sysclk xx 1 0x2b 28800 -0.32% 848 sysclk / 4 01 0 0x96 14400 0.15% 1704 sysclk / 12 00 0 0xb9 9600 -0.32% 2544 sysclk / 12 00 0 0x96 2400 -0.32% 10176 sysclk / 48 10 0 0x96 1200 0.15% 20448 sysclk / 48 10 0 0x2b x=dontcare ? sca1-sca0 and t1m bit definitions can be found in section 23.1 . table 22.2. timer settings for standard baud rates using an external oscillator frequency: 25.0 mhz target baud rate (bps) baud rate %error oscillator divide factor timer clock source sca1-sca0 (pre-scale select) ? t1m ? timer 1 reload va lu e (h ex) sysclk from external osc. 230400 -0.47% 108 sysclk xx 1 0xca 115200 0.45% 218 sysclk xx 1 0x93 57600 -0.01% 434 sysclk xx 1 0x27 28800 0.45% 872 sysclk / 4 01 0 0x93 14400 -0.01% 1736 sysclk / 4 01 0 0x27 9600 0.15% 2608 extclk / 8 11 0 0x5d 2400 0.45% 10464 sysclk / 48 10 0 0x93 1200 -0.01% 20832 sysclk / 48 10 0 0x27 sysclk from internal osc. 57600 -0.47% 432 extclk / 8 11 0 0xe5 28800 -0.47% 864 extclk / 8 11 0 0xca 14400 0.45% 1744 extclk / 8 11 0 0x93 9600 0.15% 2608 extclk / 8 11 0 0x5d x=dontcare ? sca1-sca0 and t1m bit definitions can be found in section 23.1 .
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 269 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information table 22.3. timer settings for standard baud rates using an external oscillator frequency: 22.1184 mhz target baud rate (bps) baud rate %error oscillator divide factor timer clock source sca1-sca0 (pre-scale select) ? t1m ? timer 1 reload va lu e (h ex) sysclk from external osc. 230400 0.00% 96 sysclk xx 1 0xd0 115200 0.00% 192 sysclk xx 1 0xa0 57600 0.00% 384 sysclk xx 1 0x40 28800 0.00% 768 sysclk / 12 00 0 0xe0 14400 0.00% 1536 sysclk / 12 00 0 0xc0 9600 0.00% 2304 sysclk / 12 00 0 0xa0 2400 0.00% 9216 sysclk / 48 10 0 0xa0 1200 0.00% 18432 sysclk / 48 10 0 0x40 sysclk from internal osc. 230400 0.00% 96 extclk / 8 11 0 0xfa 115200 0.00% 192 extclk / 8 11 0 0xf4 57600 0.00% 384 extclk / 8 11 0 0xe8 28800 0.00% 768 extclk / 8 11 0 0xd0 14400 0.00% 1536 extclk / 8 11 0 0xa0 9600 0.00% 2304 extclk / 8 11 0 0x70 x=dontcare ? sca1-sca0 and t1m bit definitions can be found in section 23.1 . table 22.4. timer settings for standard baud rates using an external oscillator frequency: 18.432 mhz target baud rate (bps) baud rate %error oscillator divide factor timer clock source sca1-sca0 (pre-scale select) ? t1m ? timer 1 reload va lu e (h ex) sysclk from external osc. 230400 0.00% 80 sysclk xx 1 0xd8 115200 0.00% 160 sysclk xx 1 0xb0 57600 0.00% 320 sysclk xx 1 0x60 28800 0.00% 640 sysclk / 4 01 0 0xb0 14400 0.00% 1280 sysclk / 4 01 0 0x60 9600 0.00% 1920 sysclk / 12 00 0 0xb0 2400 0.00% 7680 sysclk / 48 10 0 0xb0 1200 0.00% 15360 sysclk / 48 10 0 0x60 sysclk from internal osc. 230400 0.00% 80 extclk / 8 11 0 0xfb 115200 0.00% 160 extclk / 8 11 0 0xf6 57600 0.00% 320 extclk / 8 11 0 0xec 28800 0.00% 640 extclk / 8 11 0 0xd8 14400 0.00% 1280 extclk / 8 11 0 0xb0 9600 0.00% 1920 extclk / 8 11 0 0x88 x=dontcare ? sca1-sca0 and t1m bit definitions can be found in section 23.1 .
page 270 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n table 22.5. timer settings for standard baud rates using an external oscillator frequency: 11.0592 mhz target baud rate (bps) baud rate %error oscillator divide factor timer clock source sca1-sca0 (pre-scale select) ? t1m ? timer 1 reload va lu e (h ex) sysclk from external osc. 230400 0.00% 48 sysclk xx 1 0xe8 115200 0.00% 96 sysclk xx 1 0xd0 57600 0.00% 192 sysclk xx 1 0xa0 28800 0.00% 384 sysclk xx 1 0x40 14400 0.00% 768 sysclk / 12 00 0 0xe0 9600 0.00% 1152 sysclk / 12 00 0 0xd0 2400 0.00% 4608 sysclk / 12 00 0 0x40 1200 0.00% 9216 sysclk / 48 10 0 0xa0 sysclk from internal osc. 230400 0.00% 48 extclk / 8 11 0 0xfd 115200 0.00% 96 extclk / 8 11 0 0xfa 57600 0.00% 192 extclk / 8 11 0 0xf4 28800 0.00% 384 extclk / 8 11 0 0xe8 14400 0.00% 768 extclk / 8 11 0 0xd0 9600 0.00% 1152 extclk / 8 11 0 0xb8 x=dontcare ? sca1-sca0 and t1m bit definitions can be found in section 23.1 . table 22.6. timer settings for standard baud rates using an external oscillator frequency: 3.6864 mhz target baud rate (bps) baud rate %error oscillator divide factor timer clock source sca1-sca0 (pre-scale select) ? t1m ? timer 1 reload va lu e (h ex) sysclk from external osc. 230400 0.00% 16 sysclk xx 1 0xf8 115200 0.00% 32 sysclk xx 1 0xf0 57600 0.00% 64 sysclk xx 1 0xe0 28800 0.00% 128 sysclk xx 1 0xc0 14400 0.00% 256 sysclk xx 1 0x80 9600 0.00% 384 sysclk xx 1 0x40 2400 0.00% 1536 sysclk / 12 00 0 0xc0 1200 0.00% 3072 sysclk / 12 00 0 0x80 sysclk from internal osc. 230400 0.00% 16 extclk / 8 11 0 0xff 115200 0.00% 32 extclk / 8 11 0 0xfe 57600 0.00% 64 extclk / 8 11 0 0xfc 28800 0.00% 128 extclk / 8 11 0 0xf8 14400 0.00% 256 extclk / 8 11 0 0xf0 9600 0.00% 384 extclk / 8 11 0 0xe8 x=dontcare ? sca1-sca0 and t1m bit definitions can be found in section 23.1 .
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 271 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 23. timers each mcu includes 5 counter/timers: timer 0 and timer 1 are 16-bit counter/timers compatible with those found in the standard 8051. timer 2,timer 3,and timer 4 are 16-bit auto-reload and capture counter/timers for use with the adc,dacs,square-wave generation,or for general-purpose use. these timers can be used to measure time inter- vals,count external events and generate periodic interrupt requests. timer 0 and timer 1 are nearly identical and have four primary modes of operation. timers 2,3,and 4 are identical,and offer not only 16-bit auto-reload and capture, but have the ability to produce a 50% duty-cycle square-wave (toggle output) at an external port pin. timers 0 and 1 may be clocked by one of five sources,determined by the timer mode select bits (t1m-t0m) and the clock scale bits (sca1-sca0). the clock scale bits define a pre-scaled clock by which timer 0 and/or timer 1 may be clocked (see figure 23.6 for pre-scaled clock selection). timer 0/1 may then be configured to use this pre-scaled clock signal or the system clock. timers 2,3,and 4 may be clocked by the system clock,the system clock divided by 12,or the external oscillator clock source divided by 8. timer 0 and timer 1 may also be operated as counters. when functioning as a counter,a counter/timer register is incremented on each high-to-low transition at the selected input pin. events with a frequency of up to one-fourth the system clock's frequency can be counted. the input signal need not be periodic,but it should be held at a given logic level for at least two full system clock cycles to ensure the level is properly sampled. 23.1. timer 0 and timer 1 each timer is implemented as 16-bit register accessed as two separate bytes: a low byte (tl0 or tl1) and a high byte (th0 or th1). the counter/timer control register (tcon) is used to enable timer 0 and timer 1 as well as indicate their status. timer 0 interrupts can be enabled by setting the et0 bit in the ie register ( section 12.3.5. interrupt register descriptions on page 146 ); timer 1 interrupts can be enabled by setting the et1 bit in the ie register ( section 12.3.5 ). both counter/timers operate in one of four primary modes selected by setting the mode select bits t1m1-t0m0 in the counter/timer mode register (tmod). each timer can be configured independently. 23.1.1. mode 0: 13-bit counter/timer timer 0 and timer 1 operate as 13-bit counter/timers in mode 0. the following describes the configuration and oper- ation of timer 0. however,both timers operate identically,and timer 1 is configured in the same manner as described for timer 0. the th0 register holds the eight msbs of the 13-bit counter/timer. tl0 holds the five lsbs in bit positions tl0.4- tl0.0. the three upper bits of tl0 (tl0.7-tl0.5) are indeterminate and should be masked out or ignored when read- ing. as the 13-bit timer register increments and overflows from 0x1fff (all ones) to 0x0000,the timer overflow flag tf0 (tcon.5) is set and an interrupt will occur if timer 0 interrupts are enabled. the c/t0 bit (tmod.2) selects the counter/timer's clock source. when c/t0 is set to logic 1,high-to-low transitions at the selected timer 0 input pin (t0) increment the timer register (refer to section 17.1. ports 0 through 3 and the priority crossbar decoder on page 193 for information on selecting and configuring external i/o pins). clear- ing c/t selects the clock defined by the t0m bit (ckcon.3). when t0m is set,timer 0 is clocked by the system clock. when t0m is cleared,timer 0 is clocked by the source selected by the clock scale bits in ckcon (see figure 23.6). timer 0 and timer 1 modes: timer 2, 3, and 4 modes: 13-bit counter/timer 16-bit counter/timer with auto-reload 16-bit counter/timer 16-bit counter/timer with capture 8-bit counter/timer with auto-reload toggle output two 8-bit counter/timers (timer 0 only)
page 272 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n setting the tr0 bit (tcon.4) enables the timer when either gate0 (tmod.3) is logic 0 or the input signal /int0 is logic-level 1. setting gate0 to 1 allows the timer to be controlled by the external input signal /int0 (see section 12.3.5. interrupt register descriptions on page 146 ),facilitating pulse width measurements. setting tr0 does not force the timer to reset. the timer registers should be loaded with the desired initial value before the timer is enabled. tl1 and th1 form the 13-bit register for timer 1 in the same manner as described above for tl0 and th0. timer 1 is configured and controlled using the relevant tcon and tmod bits just as with timer 0. the input signal /int1 is used with timer 1. 23.1.2. mode 1: 16-bit counter/timer mode 1 operation is the same as mode 0,except that the counter/timer registers use all 16 bits. the counter/timers are enabled and configured in mode 1 in the same manner as for mode 0. tr0 gate0 /int0 counter/timer 0xxdisabled 10xenabled 110disabled 111enabled x = don't care figure 23.1. t0 mode 0 block diagram tclk tl0 (5 bits) th0 (8 bits) tcon tf0 tr0 tr1 tf1 ie1 it1 ie0 it0 interrupt tr0 0 1 0 1 sysclk pre-scaled clock ckcon s c a 0 s c a 1 t 1 m t 0 m tmod t 1 m 1 t 1 m 0 c / t 1 g a t e 1 g a t e 0 c / t 0 t 0 m 1 t 0 m 0 gate0 /int0 t0 crossbar
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 273 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 23.1.3. mode 2: 8-bit counter/timer with auto-reload mode 2 configures timer 0 and timer 1 to operate as 8-bit counter/timers with automatic reload of the start value. tl0 holds the count and th0 holds the reload value. when the counter in tl0 overflows from 0xff to 0x00,the timer overflow flag tf0 (tcon.5) is set and the counter in tl0 is reloaded from th0. if timer 0 interrupts are enabled,an interrupt will occur when the tf0 flag is set. the reload value in th0 is not changed. tl0 must be initial- ized to the desired value before enabling the timer for the first count to be correct. when in mode 2,timer 1 operates identically to timer 0. both counter/timers are enabled and configured in mode 2 in the same manner as mode 0. setting the tr0 bit (tcon.4) enables the timer when either gate0 (tmod.3) is logic 0 or when the input signal /int0 is low. figure 23.2. t0 mode 2 block diagram tclk tmod t 1 m 1 t 1 m 0 c / t 1 g a t e 1 g a t e 0 c / t 0 t 0 m 1 t 0 m 0 tcon tf0 tr0 tr1 tf1 ie1 it1 ie0 it0 interrupt tl0 (8 bits) reload th0 (8 bits) 0 1 0 1 sysclk pre-scaled clock ckcon s c a 0 s c a 1 t 1 m t 0 m tr0 gate0 /int0 t0 crossbar
page 274 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 23.1.4. mode 3: two 8-bit counter/timers (timer 0 only) in mode 3,timer 0 is configured as two separate 8-bit counter/timers held in tl0 and th0. the counter/timer in tl0 is controlled using the timer 0 control/status bits in tcon and tmod: tr0,c/t0,gate0 and tf0. tl0 can use either the system clock or an external input signal as its timebase. the th0 register is restricted to a timer function sourced by the system clock or prescaled clock. th0 is enabled using the timer 1 run control bit tr1. th0 sets the timer 1 overflow flag tf1 on overflow and thus controls the timer 1 interrupt. timer 1 is inactive in mode 3. when timer 0 is operating in mode 3,timer 1 can be operated in modes 0,1 or 2,but cannot be clocked by external signals nor set the tf1 flag and generate an interrupt. however,the timer 1 overflow can be used to generate baud rates for the smbus and/or uart,and/or initiate adc conversions. while timer 0 is operating in mode 3,timer 1 run control is handled through its mode settings. to run timer 1 while timer 0 is in mode 3,set the timer 1 mode as 0,1,or 2. to disable timer 1,configure it for mode 3. figure 23.3. t0 mode 3 block diagram tl0 (8 bits) tmod 0 1 tcon tf0 tr0 tr1 tf1 ie1 it1 ie0 it0 interrupt interrupt 0 1 sysclk pre-scaled clock tr1 th0 (8 bits) ckcon s c a 0 s c a 1 t 1 m t 0 m t 1 m 1 t 1 m 0 c / t 1 g a t e 1 g a t e 0 c / t 0 t 0 m 1 t 0 m 0 tr0 gate0 /int0 t0 crossbar
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 275 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 23.4. tcon: timer control register bit7: tf1: timer 1 overflow flag. set by hardware when timer 1 overflows. this flag can be cleared by software but is automatically cleared when the cpu vectors to the timer 1 interrupt service routine. 0: no timer 1 overflow detected. 1: timer 1 has overflowed. bit6: tr1: timer 1 run control. 0: timer 1 disabled. 1: timer 1 enabled. bit5: tf0: timer 0 overflow flag. set by hardware when timer 0 overflows. this flag can be cleared by software but is automatically cleared when the cpu vectors to the timer 0 interrupt service routine. 0: no timer 0 overflow detected. 1: timer 0 has overflowed. bit4: tr0: timer 0 run control. 0: timer 0 disabled. 1: timer 0 enabled. bit3: ie1: external interrupt 1. this flag is set by hardware when an edge/level of type defined by it1 is detected. it can be cleared by software but is automatically cleared when the cpu vectors to the external interrupt 1 service routine if it1 = 1. this flag is the inverse of the /int1 signal. bit2: it1: interrupt 1 type select. this bit selects whether the configured /int1 interrupt will be falling-edge sensitive or active-low. 0: /int1 is level triggered,active-low. 1: /int1 is edge triggered,falling-edge. bit1: ie0: external interrupt 0. this flag is set by hardware when an edge/level of type defined by it0 is detected. it can be cleared by software but is automatically cleared when the cpu vectors to the external interrupt 0 service routine if it0 = 1. this flag is the inverse of the /int0 signal. bit0: it0: interrupt 0 type select. this bit selects whether the configured /int0 interrupt will be falling-edge sensitive or active-low. 0: /int0 is level triggered,active logic-low. 1: /int0 is edge triggered,falling-edge. r/w r/w r/w r/w r/w r/w r/w r/w reset value tf1 tr1 tf0 tr0 ie1 it1 ie0 it0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0x88 0
page 276 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 23.5. tmod: timer mode register bit7: gate1: timer 1 gate control. 0: timer 1 enabled when tr1 = 1 irrespective of /int1 logic level. 1:timer1enabledonlywhentr1=1and/int1=logic1. bit6: c/t1: counter/timer 1 select. 0: timer function: timer 1 incremented by clock defined by t1m bit (ckcon.4). 1: counter function: timer 1 incremented by high-to-low transitions on external input pin (t1). bits5-4: t1m1-t1m0: timer 1 mode select. these bits select the timer 1 operation mode. bit3: gate0: timer 0 gate control. 0: timer 0 enabled when tr0 = 1 irrespective of /int0 logic level. 1:timer0enabledonlywhentr0=1and/int0=logic1. bit2: c/t0: counter/timer select. 0: timer function: timer 0 incremented by clock defined by t0m bit (ckcon.3). 1: counter function: timer 0 incremented by high-to-low transitions on external input pin (t0). bits1-0: t0m1-t0m0: timer 0 mode select. these bits select the timer 0 operation mode. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue gate1 c/t1 t1m1 t1m0 gate0 c/t0 t0m1 t0m0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x89 0 t1m1 t1m0 mode 0 0 mode 0: 13-bit counter/timer 0 1 mode 1: 16-bit counter/timer 1 0 mode 2: 8-bit counter/timer with auto-reload 1 1 mode 3: timer 1 inactive t0m1 t0m0 mode 0 0 mode 0: 13-bit counter/timer 0 1 mode 1: 16-bit counter/timer 1 0 mode 2: 8-bit counter/timer with auto-reload 1 1 mode 3: two 8-bit counter/timers
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 277 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 23.6. ckcon: clock control register bits7-5: unused. read = 000b,write = dont care. bit4: t1m: timer 1 clock select. this select the clock source supplied to timer 1. t1m is ignored when c/t1 is set to logic 1. 0: timer 1 uses the clock defined by the prescale bits,sca1-sca0. 1: timer 1 uses the system clock. bit3: t0m: timer 0 clock select. this bit selects the clock source supplied to timer 0. t0m is ignored when c/t0 is set to logic 1. 0: counter/timer 0 uses the clock defined by the prescale bits,sca1-sca0. 1: counter/timer 0 uses the system clock. bit2: unused. read = 0b,write = dont care. bits1-0: sca1-sca0: timer 0/1 prescale bits these bits control the division of the clock supplied to timer 0 and/or timer 1 if configured to use prescaled clock inputs. ?note: external clock divided by 8 is synchronized with the system clock,and external clock must be less than or equal to the system clock frequency to operate the timer in this mode. r/w r/w r/w r/w r/w r/w r/w r/w reset value - - - t1m t0m - sca1 sca0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x8e 0 sca1 sca0 prescaled clock 0 0 system clock divided by 12 0 1 system clock divided by 4 1 0 system clock divided by 48 1 1 external clock divided by 8?
page 278 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 23.7. tl0: timer 0 low byte bits 7-0: tl0: timer 0 low byte. the tl0 register is the low byte of the 16-bit timer 0 r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x8a 0 figure 23.8. tl1: timer 1 low byte bits 7-0: tl1: timer 1 low byte. the tl1 register is the low byte of the 16-bit timer 1. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x8b 0 figure 23.9. th0: timer 0 high byte bits 7-0: th0: timer 0 high byte. the th0 register is the high byte of the 16-bit timer 0. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x8c 0 figure 23.10. th1: timer 1 high byte bits 7-0: th1: timer 1 high byte. the th1 register is the high byte of the 16-bit timer 1. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x8d 0
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 279 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 23.2. timer 2, timer 3, and timer 4 timers 2,3,and 4 are 16-bit counter/timers,each formed by two 8-bit sfrs: tmrnl (low byte) and tmrnh (high byte) where n = 2,3,and 4 for timers 2,3,and 4 respectively. these timers feature auto-reload,capture,and toggle output modes with the ability to count up or down. capture mode and auto-reload mode are selected using bits in the timer 2,3,and 4 control registers (tmrncn). toggle output mode is selected using the timer 2,3,and 4 configu- ration registers (tmrncf). these timers may also be used to generate a square-wave at an external pin. as with timers 0 and 1,timers 2,3,and 4 can use either the system clock (divided by one,two,or twelve),external clock (divided by eight) or transitions on an external input pin as its clock source. the counter/timer select bit c/tn bit (tmrncn.1) configures the peripheral as a counter or timer. clearing c/tn configures the timer to be in a timer mode (i.e.,the system clock or transitions on an external pin as the input for the timer). when c/tn is set to 1,the timer is configured as a counter (i.e.,high-to-low transitions at the tn input pin increment (or decrement) the counter/ timer register. refer to section 17.1. ports 0 through 3 and the priority crossbar decoder on page 193 for information on selecting and configuring external i/o pins for digital peripherals,such as the tn pin. timer 2 and 3 can be used to start an adc data conversion and timers 2,3,and 4 can schedule dac outputs. only timer 1 can be used to generate baud rates for uart 1,and timers 1,2,3,or 4 may be used to generate baud rates for uart 0. timer 2,3,and 4 can use either sysclk,sysclk divided by 2,sysclk divided by 12,an external clock divided by 8,or high-to-low transitions on the tn input pin as its clock source when operating in counter/timer with capture mode. clearing the c/tn bit (tncon.1) selects the system clock/external clock as the input for the timer. the timer clock select bits tnm0 and tnm1 in tmrncf can be used to select the system clock undivided,system clock divided by two,system clock divided by 12,or an external clock provided at the xtal1/xtal2 pins divided by 8 (see figure 23.14). when c/tn is set to logic 1,a high-to-low transition at the tn input pin increments the counter/ timer register (i.e.,configured as a counter). 23.2.1. configuring timer 2, 3, and 4 to count down timers 2,3,and 4 have the ability to count down. when the timers respective decrement enable bit (dcen) in the timer configuration register (see figure 23.14) is set to 1,the timer can then count up or down .whendcen=1, the direction of the timers count is controlled by the tnex pins logic level. when tnex = 1,the counter/timer will count up; when tnex = 0,the counter/timer will count down. to use this feature,tnex must be enabled in the digi- tal crossbar and configured as a digital input. note: when dcen = 1, other functions of the tnex input (i.e., capture and auto-reload) are not available. tnex will only control the direction of the timer when dcen= 1.
page 280 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 23.2.2. capture mode in capture mode,timer 2,3,and 4 will operate as a 16-bit counter/timer with capture facility. when the timer exter- nal enable bit (found in the tmrncn register) is set to 1,a high-to-low transition on the tnex input pin causes the 16-bit value in the associated timer (thn,tln) to be loaded into the capture registers (rcapnh,rcapnl). if a cap- ture is triggered in the counter/timer,the timer external flag (tmrncn.6) will be set to 1 and an interrupt will occur if the interrupt is enabled. see section 12.3. interrupt handler on page 143 for further information con- cerning the configuration of interrupt sources. as the 16-bit timer register increments and overflows tmrnh:tmrnl,the tfn timer overflow/underflow flag (tmrncn.7) is set to 1 and an interrupt will occur if the interrupt is enabled. the timer can be configured to count down by setting the decrement enable bit (tmrncf.0) to 1. this will cause the timer to decrement with every timer clock/count event and underflow when the timer transitions from 0x0000 to 0xffff. just as in overflows,the overflow/underflow flag (tfn) will be set to 1,and an interrupt will occur if enabled. counter/timer with capture mode is selected by setting the capture/reload select bit cp/rln (tmrncn.0) and the timer 2,3,and 4 run control bit trn (tncon.2) to logic 1. the timer 2,3,and 4 respective external enable exenn (tncon.3) must also be set to logic 1 to enable a captures. if exenn is cleared,transitions on tnex will be ignored. tmrnl tmrnh trn tclk interrupt tncon exfn exenn trn c/tn cp/rln tfn sysclk 12 2 tmrncf d c e n t n o e t o g n t n m 1 t n m 0 toggle logic tn (port pin) 0 1 1 0 exenn crossbar tnex rcapnl rcapnh 0xff 0xff 8 external clock (xtal1) tn crossbar ovf capture figure 23.11. t2, 3, and 4 capture mode block diagram
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 281 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 23.2.3. auto-reload mode in auto-reload mode,the counter/timer can be configured to count up or down and cause an interrupt/flag to occur upon an overflow/underflow event. when counting up,the counter/timer will set its overflow/underflow flag (tfn) and cause an interrupt (if enabled) upon overflow/underflow,and the values in the reload/capture registers (rcapnh and rcapnl) are loaded into the timer and the timer is restarted. when the timer external enable bit (exenn) bit is set to 1 and the decrement enable bit (dcen) is 0,a falling edge (1-to-0 transition) on the tnex pin (configured as an input in the digital crossbar) will cause a timer reload (in addition to timer overflows causing auto-reloads). when dcen is set to 1,the state of the tnex pin controls whether the counter/timer counts up (increments) or down (decrements),and will not cause an auto-reload or interrupt event. see section 23.2.1 for information concerning configuration of a timer to count down. when counting down,the counter/timer will set its overflow/underflow flag (tfn) and cause an interrupt (if enabled) when the value in the timer (tmrnh and tmrnl registers) matches the 16-bit value in the reload/capture registers (rcapnh and rcapnl). this is considered an underflow event,and will cause the timer to load the value 0xffff. the timer is automatically restarted when an underflow occurs. counter/timer with auto-reload mode is selected by clearing the cp/rln bit. setting trn to logic 1 enables and starts the timer. in auto-reload mode,the external flag (exfn) toggles upon every overflow or underflow and does not cause an interrupt. the exfn flag can be thought of as the most significant bit (msb) of a 17-bit counter. . 23.2.4. toggle output mode timer 2,3,and 4 have the capability to toggle the state of their respective output port pins (t2,t3,or t4) to produce a 50% duty cycle waveform output. the port pin state will change upon the overflow or underflow of the respective timer (depending on whether the timer is counting up or down ). the toggle frequency is determined by the clock tmrnl tmrnh trn tclk reload interrupt exenn crossbar tnex tncon exfn exenn trn c/tn cp/rln tfn sysclk 12 2 tmrncf d c e n t n o e t o g n t n m 1 t n m 0 toggle logic tn (port pin) 0 1 1 0 rcapnl rcapnh 0xff 0xff ovf 8 external clock (xtal1) tn crossbar smbus (timer 4 only) figure 23.12. t2, 3, and 4 auto-reload mode block diagram
page 282 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n source of the timer and the values loaded into rcapnh and rcapnl. when counting down,the auto-reload value for the timer is 0xffff,and underflow will occur when the value in the timer matches the value stored in rcapnh:rcapnl. when counting up,the auto-reload value for the timer is rcapnh:rcapnl,and overflow will occur when the value in the timer transitions from 0xffff to the reload value. to output a square wave,the timer is placed in reload mode (the capture/reload select bit in tmrncn and the timer/counter select bit in tmrncn are cleared to 0). the timer output is enabled by setting the timer output enable bit in tmrncf to 1. the timer should be configured via the timer clock source and reload/underflow values such that the timer overflow/underflows at 1/2 the desired output frequency. the port pin assigned by the crossbar as the timers output pin should be configured as a digital output (see section 17. port input/output on page 191 ). setting the timers run bit (trn) to 1 will start the toggle of the pin. a read/write of the timers tog- gle output state bit (tmrncf.2) is used to read the state of the toggle output,or to force a value of the output. this is useful when it is desired to start the toggle of a pin in a known state,or to force the pin into a desired state when the toggle mode is halted. f sq 2 f tclk ---------------- - 65535 rcapn C () ? = equation 23.1. square wave frequency if timer is configured to count up: if timer is configured to count down: f sq 2 f tclk ---------------- - rcapn () ? =
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 283 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information bit7: tfn: timer 2,3,and 4 overflow/underflow flag. set by hardware when either the timer overflows from 0xffff to 0x0000,underflows from the value placed in rcapnh:rcapnl to 0xffff (in auto-reload mode),or underflows from 0x0000 to 0xffff (in capture mode). when the timer interrupt is enabled,setting this bit causes the cpu to vector to the timer interrupt service routine. this bit is not automatically cleared by hardware and must be cleared by software. bit6: exfn: timer 2,3,or 4 external flag. set by hardware when either a capture or reload is caused by a high-to-low transition on the tnex input pin and exenn is logic 1. when the timer interrupt is enabled,setting this bit causes the cpu to vector to the timer interrupt service routine. this bit is not automatically cleared by hardware and must be cleared by software. bit5-4: reserved. bit3: exenn: timer 2,3,and 4 external enable. enables high-to-low transitions on tnex to trigger captures,reloads,and control the direction of the timer/counter (up or down count). if decen = 1,tnex will determine if the timer counts up or down when in auto-reload mode. if exenn = 1,tnex should be configured as a digital input. 0: transitions on the tnex pin are ignored. 1: transitions on the tnex pin cause capture,reload,or control the direction of timer count (up or down) as follows: capture mode : 1-to-0 transition on tnex pin causes rcapnh:rcapnl to capture timer value. auto-reload mode : dcen = 0: 1-to-0 transition causes reload of timer and sets the exfn flag. dcen = 1: tnex logic level controls direction of timer (up or down). bit2: trn: timer 2,3,and 4 run control. this bit enables/disables the respective timer. 0: timer disabled. 1: timer enabled and running/counting. bit1: c/tn: counter/timer select. 0: timer function: timer incremented by clock defined by tnm1:tnm0 (tmrncf.4:tmrncf.3). 1: counter function: timer incremented by high-to-low transitions on external input pin. bit0: cp/rln: capture/reload select. this bit selects whether the timer functions in capture or auto-reload mode. 0: timer is in auto-reload mode. 1: timer is in capture mode. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue tfn exfn - - exenn trn c/tn cp/rln 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: tmr2cn: 0xc8; tmr3cn: 0xc8; tmr4cn: 0xc8 sfr page: tmr2cn: page 0; tmr3cn: page 1; tmr4cn: page 2 figure 23.13. tmrncn: timer 2, 3, and 4 control registers
page 284 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n bit7-5: reserved. bit4-3: tnm1 and tnm0: timer clock mode select bits. bits used to select the timer clock source. the sources can be the system clock (sysclk), sysclk divided by 2 or 12,or an external clock signal routed to tn (port pin) divided by 8. clock source is selected as follows: 00: sysclk/12 01: sysclk 10: external clock/8 11: sysclk/2 bit2: togn: toggle output state bit. when timer is used to toggle a port pin,this bit can be used to read the state of the output,or can be written to in order to force the state of the output. bit1: tnoe: timer output enable bit. this bit enables the timer to output a 50% duty cycle output to the timers assigned external port pin. note : a timer is configured for square wave output as follows: cp/rln = 0 c/tn = 1 tnoe = 1 load rcapnh:rcapnl (see square wave frequency on page 282.) configure port pin to output squarewave (see section 17. port input/output on page 191 ) 0: output of toggle mode not available at timerss assigned port pin. 1: output of toggle mode available at timerss assigned port pin. bit0: dcen: decrement enable bit. this bit enables the timer to count up or down as determined by the state of tnex. 0: timer will count up,regardless of the state of tnex. 1: timer will count up or down depending on the state of tnex as follows: if tnex = 0,the timer counts down if tnex = 1,the timer counts up. r/w r/w r/w r/w r/w reset value - - - tnm1 tnm0 togn tnoe dcen 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: tmr2cf: 0xc9; tmr3cf: 0xc9; tmr4cf: 0xc9 sfr page tmr2cf: page 0; tmr3cf: page 1; tmr4cf: page 2 figure 23.14. tmrncf: timer 2, 3, and 4 configuration registers
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 285 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information bits 7-0: rcap2,3,and 4l: timer 2,3,and 4 capture register low byte. the rcap2,3,and 4l register captures the low byte of timer 2,3,and 4 when timer 2,3,and 4 is configured in capture mode. when timer 2,3,and 4 is configured in auto-reload mode,it holds the low byte of the reload value. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: rcap2l: 0xca; rcap3l: 0xca; rcap4l: 0xca sfr page: rcap2l: page 0; rcap3l: page 1; rcap4l: page 2 figure 23.15. rcapnl: timer 2, 3, and 4 capture register low byte figure 23.16. rcapnh: timer 2, 3, and 4 capture register high byte bits 7-0: rcap2,3,and 4h: timer 2,3,and 4 capture register high byte. the rcap2,3,and 4h register captures the highballed of timer 2,3,and 4 when timer 2,3,and 4 is configured in capture mode. when timer 2,3,and 4 is configured in auto-reload mode,it holds the high byte of the reload value. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: rcap2h: 0xcb; rcap3h: 0xcb; rcap4h: 0xcb sfr page: rcap2h: page 0; rcap3h: page 1; rcap4h: page 2 figure 23.17. tmrnl: timer 2, 3, and 4 low byte bits 7-0: tl2,3,and 4: timer 2,3,and 4 low byte. the tl2,3,and 4 register contains the low byte of the 16-bit timer 2,3,and 4 r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: tmr2l: 0xcc; tmr3l: 0xcc; tmr4l: 0xcc sfrpage:tmr2l:page0;tmr3l:page1;tmr4l:page2
page 286 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 23.18. tmrnh timer 2, 3, and 4 high byte bits 7-0: th2,3,and 4: timer 2,3,and 4 high byte. the th2,3,and 4 register contains the high byte of the 16-bit timer 2,3,and 4 r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: tmr2h: 0xcd; tmr3h: 0xcd; tmr4h: 0xcd sfrpage:tmr2h:page0;tmr3h:page1;tmr4h:page2
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 287 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 24. programmable counter array the programmable counter array (pca0) provides enhanced timer functionality while requiring less cpu interven- tion than the standard 8051 counter/timers. pca0 consists of a dedicated 16-bit counter/timer and six 16-bit capture/ compare modules. each capture/compare module has its own associated i/o line (cexn) which is routed through the crossbar to port i/o when enabled (see section 17.1. ports 0 through 3 and the priority crossbar decoder on page 193 ). the counter/timer is driven by a programmable timebase that can select between six inputs as its source: system clock,system clock divided by four,system clock divided by twelve,the external oscillator clock source divided by 8,timer 0 overflow,or an external clock signal on the eci line. each capture/compare module may be configured to operate independently in one of six modes: edge-triggered capture,software timer,high-speed out- put,frequency output,8-bit pwm,or 16-bit pwm (each is described in section 24.2 ). the pca is configured and controlled through the system controller's special function registers. the basic pca block diagram is shown in figure 24.1. figure 24.1. pca block diagram capture/compare module 1 capture/compare module 0 capture/compare module 2 capture/compare module 3 cex1 eci crossbar cex2 cex3 cex0 port i/o 16-bit counter/timer pca clock mux sysclk/12 sysclk/4 timer 0 overflow eci sysclk external clock/8 capture/compare module 4 cex4 capture/compare module 5 cex5
page 288 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 24.1. pca counter/timer the 16-bit pca counter/timer consists of two 8-bit sfrs: pca0l and pca0h. pca0h is the high byte (msb) of the 16-bit counter/timer and pca0l is the low byte (lsb). reading pca0l automatically latches the value of pca0h into a snapshot register; the following pca0h read accesses this snapshot register. reading the pca0l register first guarantees an accurate reading of the entire 16-bit pca0 counter. reading pca0h or pca0l does not disturb the counter operation. the cps2-cps0 bits in the pca0md register select the timebase for the counter/timer as shown in table 24.1. when the counter/timer overflows from 0xffff to 0x0000,the counter overflow flag (cf) in pca0md is set to logic 1 and an interrupt request is generated if cf interrupts are enabled. setting the ecf bit in pca0md to logic 1 enables the cf flag to generate an interrupt request. the cf bit is not automatically cleared by hardware when the cpu vectors to the interrupt service routine,and must be cleared by software (note: pca0 interrupts must be glo- bally enabled before cf interrupts are recognized. pca0 interrupts are globally enabled by setting the ea bit (ie.7) and the epca0 bit in eie1 to logic 1). clearing the cidl bit in the pca0md register allows the pca to continue normal operation while the cpu is in idle mode. table 24.1. pca timebase input options cps2 cps1 cps0 timebase 0 0 0 system clock divided by 12 0 0 1 system clock divided by 4 010timer0overflow 0 1 1 high-to-low transitions on eci (max rate = system clock divided by 4) 1 0 0 system clock 101 external oscillator source divided by 8 (synchronized with system clock) figure 24.2. pca counter/timer block diagram pca0md c i d l w d t e e c f c p s 1 c p s 0 w d l c k c p s 2 idle 0 1 pca0h pca0l snapshot register to sfr bus overflow to pca interrupt system cf pca0l read to pca modules sysclk/12 sysclk/4 timer 0 overflow eci 000 001 010 011 100 101 sysclk external clock/8 pca0cn c f c r c c f 0 c c f 2 c c f 1 c c f 5 c c f 4 c c f 3
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 289 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 24.2. capture/compare modules each module can be configured to operate independently in one of six operation modes: edge-triggered capture, software timer,high speed output,frequency output,8-bit pulse width modulator,or 16-bit pulse width modu- lator. each module has special function registers (sfrs) associated with it in the cip-51 system controller. these registers are used to exchange data with a module and configure the module's mode of operation. table 24.2 summarizes the bit settings in the pca0cpmn registers used to select the pca0 capture/compare mod- ules operating modes. setting the eccfn bit in a pca0cpmn register enables the module's ccfn interrupt. note: pca0 interrupts must be globally enabled before individual ccfn interrupts are recognized. pca0 interrupts are glo- bally enabled by setting the ea bit (ie.7) and the epca0 bit (eie1.3) to logic 1. see figure 24.3 for details on the pca interrupt configuration. table 24.2. pca0cpm register settings for pca capture/compare modules pwm16 ecom capp capnmat tog pwm eccf operation mode x x 10000x capture triggered by positive edge on cexn x x 01000x capture triggered by negative edge on cexn x x 11000x capture triggered by transition on cexn x 1 00100x softwaretimer x 1 00110x highspeedoutput x 1 00011x frequencyoutput 0 1 000010 8-bitpulsewidthmodulator 1 1 000010 16-bitpulsewidthmodulator x = dont care figure 24.3. pca interrupt block diagram pca0cn c f c r c c f 0 c c f 2 c c f 1 c c f 5 c c f 4 c c f 3 pca0md c i d l e c f c p s 1 c p s 0 c p s 2 0 1 pca module 0 pca module 1 eccf1 0 1 eccf0 0 1 pca module 2 eccf2 0 1 pca module 3 eccf3 eccf4 pca counter/ timer overflow 0 1 interrupt priority decoder epca0 (eie.3) pca0cpmn (forn=0to5) p w m 1 6 n e c o m n e c c f n t o g n p w m n c a p p n c a p n n m a t n 0 1 pca module 4 0 1 pca module 5 0 1 ea (ie.7) 0 1 eccf5
page 290 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 24.2.1. edge-triggered capture mode in this mode,a valid transition on the cexn pin causes pca0 to capture the value of the pca0 counter/timer and load it into the corresponding module's 16-bit capture/compare register (pca0cpln and pca0cphn). the cappn and capnn bits in the pca0cpmn register are used to select the type of transition that triggers the capture: low-to- high transition (positive edge),high-to-low transition (negative edge),or either transition (positive or negative edge). when a capture occurs,the capture/compare flag (ccfn) in pca0cn is set to logic 1 and an interrupt request is generated if ccf interrupts are enabled. the ccfn bit is not automatically cleared by hardware when the cpu vec- tors to the interrupt service routine,and must be cleared by software. note: the signal at cexn must be high or low for at least 2 system clock cycles in order to be valid. figure 24.4. pca capture mode diagram pca0l pca0cpln pca timebase cexn crossbar port i/o pca0h capture pca0cphn 0 1 0 1 (to ccfn) pca interrupt pca0cpmn p w m 1 6 n e c o m n e c c f n t o g n p w m n c a p p n c a p n n m a t n pca0cn c f c r c c f 0 c c f 2 c c f 1 c c f 5 c c f 4 c c f 3
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 291 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 24.2.2. software timer (compare) mode in software timer mode,the pca0 counter/timer is compared to the module's 16-bit capture/compare register (pca0cphn and pca0cpln). when a match occurs,the capture/compare flag (ccfn) in pca0cn is set to logic 1 and an interrupt request is generated if ccf interrupts are enabled. the ccfn bit is not automatically cleared by hardware when the cpu vectors to the interrupt service routine,and must be cleared by software. setting the ecomn and matn bits in the pca0cpmn register enables software timer mode. figure 24.5. pca software timer mode diagram match 16-bit comparator pca0h pca0cphn enable pca0l pca timebase pca0cpln 00 00 pca interrupt 0 1 x enb enb 0 1 write to pca0cpln write to pca0cphn reset pca0cpmn p w m 1 6 n e c o m n e c c f n t o g n p w m n c a p p n c a p n n m a t n x pca0cn c f c r c c f 0 c c f 2 c c f 1 c c f 5 c c f 4 c c f 3
page 292 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 24.2.3. high speed output mode in high speed output mode,a modules associated cexn pin is toggled each time a match occurs between the pca counter and the module's 16-bit capture/compare register (pca0cphn and pca0cpln) setting the togn,matn, and ecomn bits in the pca0cpmn register enables the high-speed output mode. figure 24.6. pca high speed output mode diagram match 16-bit comparator pca0h pca0cphn enable pca0l pca timebase pca0cpln pca interrupt 0 1 00 0x enb enb 0 1 write to pca0cpln write to pca0cphn reset pca0cpmn p w m 1 6 n e c o m n e c c f n t o g n p w m n c a p p n c a p n n m a t n x cexn crossbar port i/o toggle 0 1 togn pca0cn c f c r c c f 0 c c f 2 c c f 1 c c f 5 c c f 4 c c f 3
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 293 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 24.2.4. frequency output mode frequency output mode produces a programmable-frequency square wave on the modules associated cexn pin. the capture/compare module high byte holds the number of pca clocks to count before the output is toggled. the frequency of the square wave is then defined by equation 24.1. where f pca is the frequency of the clock selected by the cps2-0 bits in the pca mode register,pca0md. the lower byte of the capture/compare module is compared to the pca0 counter low byte; on a match,cexn is toggled and the offset held in the high byte is added to the matched value in pca0cpln. frequency output mode is enabled by setting the ecomn,togn,and pwmn bits in the pca0cpmn register. equation 24.1. square wave frequency output f sqr f pca 2 pca 0 cphn ---------------------------------------- - = 8-bit comparator pca0l enable pca timebase 000 0 match pca0cpmn p w m 1 6 n e c o m n e c c f n t o g n p w m n c a p p n c a p n n m a t n 0 pca0cphn 8-bit adder pca0cpln adder enable cexn crossbar port i/o toggle 0 1 togn 1 figure 24.7. pca frequency output mode
page 294 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 24.2.5. 8-bit pulse width modulator mode each module can be used independently to generate pulse width modulated (pwm) outputs on its associated cexn pin. the frequency of the output is dependent on the timebase for the pca0 counter/timer. the duty cycle of the pwm output signal is varied using the module's pca0cpln capture/compare register. when the value in the low byte of the pca0 counter/timer (pca0l) is equal to the value in pca0cpln,the output on the cexn pin will be high. when the count value in pca0l overflows,the cexn output will be low (see figure 24.8). also,when the counter/timer low byte (pca0l) overflows from 0xff to 0x00,pca0cpln is reloaded automatically with the value stored in the counter/timer's high byte (pca0h) without software intervention. setting the ecomn and pwmn bits in the pca0cpmn register enables 8-bit pulse width modulator mode. the duty cycle for 8-bit pwm mode is given by equation 24.2. dutycycle 256 pca 0 cphn C () 256 --------------------------------------------------- = equation 24.2. 8-bit pwm duty cycle 8-bit comparator pca0l pca0cpln pca0cphn cexn crossbar port i/o enable overflow pca timebase 0000 0 q q set clr s r match pca0cpmn p w m 1 6 n e c o m n e c c f n t o g n p w m n c a p p n c a p n n m a t n 0 figure 24.8. pca 8-bit pwm mode diagram
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 295 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 24.2.6. 16-bit pulse width modulator mode each pca0 module may also be operated in 16-bit pwm mode. in this mode,the 16-bit capture/compare module defines the number of pca0 clocks for the low time of the pwm signal. when the pca0 counter matches the module contents,the output on cexn is asserted high; when the counter overflows,cexn is asserted low. to output a vary- ing duty cycle,new value writes should be synchronized with pca0 ccfn match interrupts. 16-bit pwm mode is enabled by setting the ecomn,pwmn,and pwm16n bits in the pca0cpmn register. for a varying duty cycle, ccfn should also be set to logic 1 to enable match interrupts. the duty cycle for 16-bit pwm mode is given by equation 24.3. 16-bit pwm duty cycle dutycycle 65536 pca 0 cpn C () 65536 ---------------------------------------------------- - = figure 24.9. pca 16-bit pwm mode pca0cpln pca0cphn enable pca timebase 0000 0 pca0cpmn p w m 1 6 n e c o m n e c c f n t o g n p w m n c a p p n c a p n n m a t n 1 16-bit comparator cexn crossbar port i/o overflow q q set clr s r match pca0h pca0l
page 296 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 24.3. register descriptions for pca0 following are detailed descriptions of the special function registers related to the operation of pca0. bit7: cf: pca counter/timer overflow flag. set by hardware when the pca0 counter/timer overflows from 0xffff to 0x0000. when the counter/timer overflow (cf) interrupt is enabled,setting this bit causes the cpu to vector to the cf interrupt service routine. this bit is not automatically cleared by hardware and must be cleared by software. bit6: cr: pca0 counter/timer run control. this bit enables/disables the pca0 counter/timer. 0: pca0 counter/timer disabled. 1: pca0 counter/timer enabled. bit5: ccf5: pca0 module 5 capture/compare flag. this bit is set by hardware when a match or capture occurs. when the ccf interrupt is enabled,set- ting this bit causes the cpu to vector to the ccf interrupt service routine. this bit is not automati- cally cleared by hardware and must be cleared by software. bit4: ccf4: pca0 module 4 capture/compare flag. this bit is set by hardware when a match or capture occurs. when the ccf interrupt is enabled,set- ting this bit causes the cpu to vector to the ccf interrupt service routine. this bit is not automati- cally cleared by hardware and must be cleared by software. bit3: ccf3: pca0 module 3 capture/compare flag. this bit is set by hardware when a match or capture occurs. when the ccf interrupt is enabled,set- ting this bit causes the cpu to vector to the ccf interrupt service routine. this bit is not automati- cally cleared by hardware and must be cleared by software. bit2: ccf2: pca0 module 2 capture/compare flag. this bit is set by hardware when a match or capture occurs. when the ccf interrupt is enabled,set- ting this bit causes the cpu to vector to the ccf interrupt service routine. this bit is not automati- cally cleared by hardware and must be cleared by software. bit1: ccf1: pca0 module 1 capture/compare flag. this bit is set by hardware when a match or capture occurs. when the ccf interrupt is enabled,set- ting this bit causes the cpu to vector to the ccf interrupt service routine. this bit is not automati- cally cleared by hardware and must be cleared by software. bit0: ccf0: pca0 module 0 capture/compare flag. this bit is set by hardware when a match or capture occurs. when the ccf interrupt is enabled,set- ting this bit causes the cpu to vector to the ccf interrupt service routine. this bit is not automati- cally cleared by hardware and must be cleared by software. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue cf cr ccf5 ccf4 ccf3 ccf2 ccf1 ccf0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd8 0 figure 24.10. pca0cn: pca control register
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 297 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 24.11. pca0md: pca0 mode register bit7: cidl: pca0 counter/timer idle control. specifies pca0 behavior when cpu is in idle mode. 0: pca0 continues to function normally while the system controller is in idle mode. 1: pca0 operation is suspended while the system controller is in idle mode. bits6-4: unused. read = 000b,write = don't care. bits3-1: cps2-cps0: pca0 counter/timer pulse select. these bits select the timebase source for the pca0 counter bit0: ecf: pca counter/timer overflow interrupt enable. this bit sets the masking of the pca0 counter/timer overflow (cf) interrupt. 0: disable the cf interrupt. 1: enable a pca0 counter/timer overflow interrupt request when cf (pca0cn.7) is set. ?note: external clock divided by 8 is synchronized with the system clock,and external clock must be less than or equal to the system clock frequency to operate in this mode. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue cidl - - - cps2 cps1 cps0 ecf 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd9 0 cps2 cps1 cps0 timebase 0 0 0 system clock divided by 12 0 0 1 system clock divided by 4 0 1 0 timer 0 overflow 011 high-to-low transitions on eci (max rate = system clock divided by 4) 1 0 0 system clock 1 0 1 external clock divided by 8? 1 1 0 reserved 1 1 1 reserved
page 298 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 24.12. pca0cpmn: pca0 capture/compare mode registers bit7: pwm16n: 16-bit pulse width modulation enable. this bit selects 16-bit mode when pulse width modulation mode is enabled (pwmn = 1). 0: 8-bit pwm selected. 1: 16-bit pwm selected. bit6: ecomn: comparator function enable. this bit enables/disables the comparator function for pca0 module n. 0: disabled. 1: enabled. bit5: cappn: capture positive function enable. this bit enables/disables the positive edge capture for pca0 module n. 0: disabled. 1: enabled. bit4: capnn: capture negative function enable. this bit enables/disables the negative edge capture for pca0 module n. 0: disabled. 1: enabled. bit3: matn: match function enable. this bit enables/disables the match function for pca0 module n. when enabled,matches of the pca0 counter with a module's capture/compare register cause the ccfn bit in pca0md register to be set to logic 1. 0: disabled. 1: enabled. bit2: togn: toggle function enable. this bit enables/disables the toggle function for pca0 module n. when enabled,matches of the pca0 counter with a module's capture/compare register cause the logic level on the cexn pin to tog- gle. if the pwmn bit is also set to logic 1,the module operates in frequency output mode. 0: disabled. 1: enabled. bit1: pwmn: pulse width modulation mode enable. this bit enables/disables the pwm function for pca0 module n. when enabled,a pulse width modu- lated signal is output on the cexn pin. 8-bit pwm is used if pwm16n is logic 0; 16-bit mode is used if pwm16n logic 1. if the togn bit is also set,the module operates in frequency output mode. 0: disabled. 1: enabled. bit0: eccfn: capture/compare flag interrupt enable. this bit sets the masking of the capture/compare flag (ccfn) interrupt. 0: disable ccfn interrupts. 1: enable a capture/compare flag interrupt request when ccfn is set. r/w r/w r/w r/w r/w r/w r/w r/w reset value pwm16n ecomn cappn capnn matn togn pwmn eecfn 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: pca0cpm0: 0xda,pca0cpm1: 0xdb,pca0cpm2: 0xdc,pca0cpm3: 0xdd,pca0cpm4: 0xde,pca0cpm5: 0xdf sfr page: pca0cpm0: page 0,pca0cpm1: page 0,pca0cpm2: page 0,pca0cpm3: 0,pca0cpm4: page 0,pca0cpm5: page 0
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 299 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information bits 7-0: pca0l: pca0 counter/timer low byte. the pca0l register holds the low byte (lsb) of the 16-bit pca0 counter/timer. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xf9 0 f i gure 24 . 13 .p c a 0 l: p c a 0c ounter / t i mer low byte bits 7-0: pca0h: pca0 counter/timer high byte. the pca0h register holds the high byte (msb) of the 16-bit pca0 counter/timer. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xfa 0 figure 24.14. pca0h: pca0 counter/timer high byte
page 300 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 24.15. pca0cpln: pca0 capture module low byte \ bits7-0: pca0cpln: pca0 capture module low byte. the pca0cpln register holds the low byte (lsb) of the 16-bit capture module n. r/wr/wr/wr/wr/wr/wr/wr/wresetvalue 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: pca0cpl0: 0xfb,pca0cpl1: 0xfd,pca0cpl2: 0xe9,pca0cpl3: 0xeb,pca0cpl4: 0xed,pca0cpl5: 0xe1 sfr page: pca0cpl0: page 0,pca0cpl1: page 0,pca0cpl2: page 0,pca0cpl3: page 0,pca0cpl4: page 0,pca0cpl5: page 0 bits7-0: pca0cphn: pca0 capture module high byte. the pca0cphn register holds the high byte (msb) of the 16-bit capture module n. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: pca0cph0: 0xfc,pca0cph1: 0xfd,pca0cph2: 0xea,pca0cph3: 0xec,pca0cph4: 0xee,pca0cph5: 0xe2 sfr page: pca0cph0: page 0,pca0cph1: page 0,pca0cph2: page 0,pca0cph3: page 0,pca0cph4: page 0,pca0cph5: page 0 figure 24.16. pca0cphn: pca0 capture module high byte
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 301 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 25. jtag (ieee 1149.1) each mcu has an on-chip jtag interface and logic to support boundary scan for production and in-system testing, flash read/write operations,and non-intrusive in-circuit debug. the jtag interface is fully compliant with the ieee 1149.1 specification. refer to this specification for detailed descriptions of the test interface and boundary-scan architecture. access of the jtag instruction register (ir) and data registers (dr) are as described in the test access port and operation of the ieee 1149.1 specification. the jtag interface is accessed via four dedicated pins on the mcu: tck,tms,tdi,and tdo. through the 16-bit jtag instruction register (ir),any of the eight instructions shown in figure 25.1 can be com- manded. there are three drs associated with jtag boundary-scan,and four associated with flash read/write oper- ations on the mcu. figure 25.1. ir: jtag instruction register reset value 0x0000 bit15 bit0 ir value instruction description 0x0000 extest selects the boundary data register for control and observability of all device pins 0x0002 sample/ preload selects the boundary data register for observability and presetting the scan-path latches 0x0004 idcode selects device id register 0xffff bypass selects bypass data register 0x0082 flash control selects flashcon register to control how the interface logic responds to reads and writes to the flashdat register 0x0083 flash data selects flashdat register for reads and writes to the flash memory 0x0084 flash address selects flashadr register which holds the address of all flash read,write,and erase operations 0x0085 flash scale selects flashscl register which controls the flash one-shot timer and read- always enable
page 302 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 25.1. boundary scan the dr in the boundary scan path is a 126-bit shift register for the C8051F060/2 and a 118-bit shift register for the c8051f061/3. the boundary dr provides control and observability of all the device pins as well as the sfr bus and weak pullup feature via the extest and sample commands. table 25.1. boundary data register bit definitions (C8051F060/2) extest provides access to both capture and update actions,while sample only performs a capture. bit action target 0captureresetenablefrommcu update reset enable to /rst pin 1 capture reset input from /rst pin update not used 2 capture can rx output enable to pin update can rx output enable to pin 3 capture can rx input from pin update can rx output to pin 4 capture can tx output enable to pin update can tx output enable to pin 5 capture can tx input from pin update can tx output to pin 6 capture external clock from xtal1 pin update not used 7 capture weak pullup enable from mcu update weak pullup enable to port pins 8,10,12,14,16,18, 20,22 capture p0.n output enable from mcu (e.g. bit 8 = p0.0,bit 10 = p0.1,etc.) update p0.n output enable to pin (e.g. bit 8 = p0.0oe,bit 10 = p0.1oe,etc.) 9,11,13,15,17,19, 21,23 capture p0.n input from pin (e.g. bit 9 = p0.0,bit 11 = p0.1,etc.) update p0.n output to pin (e.g. bit 9 = p0.0,bit 11 = p0.1,etc.) 24,26,28,30,32, 34,36,38 capture p1.n output enable from mcu (follows p0.n numbering scheme) update p1.n output enable to pin (follows p0.n numbering scheme) 25,27,29,31,33, 35,37,39 capture p1.n input from pin (follows p0.n numbering scheme) update p1.n output to pin (follows p0.n numbering scheme) 40,42,44,46,48, 50,52,54 capture p2.n output enable from mcu (follows p0.n numbering scheme) update p2.n output enable to pin (follows p0.n numbering scheme) 41,43,45,47,49, 51,53,55 capture p2.n input from pin (follows p0.n numbering scheme) update p2.n output to pin (follows p0.n numbering scheme) 56,58,60,62,64, 66,68,70 capture p3.n output enable from mcu (follows p0.n numbering scheme) update p3.n output enable to pin (follows p0.n numbering scheme) 57,59,61,63,65, 67,69,71 capture p3.n input from pin (follows p0.n numbering scheme) update p3.n output to pin (follows p0.n numbering scheme) 72,74,76 capture p4.5,p4.6,p4.7 (respectively) output enable from mcu update p4.5,p4.6,p4.7 (respectively) output enable to pin 73,75,77 capture p4.5,p4.6,p4.7 (respectively) input from pin update p4.5,p4.6,p4.7 (respectively) output to pin 78,80,82,84,86, 88,90,92 capture p5.n output enable from mcu (follows p0.n numbering scheme) update p5.n output enable to pin (follows p0.n numbering scheme) 79,81,83,85,87, 89,91,93 capture p5.n input from pin (follows p0.n numbering scheme) update p5.n output to pin (follows p0.n numbering scheme)
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 303 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 94,96,98,100,102, 104,106,108 capture p6.n output enable from mcu (follows p0.n numbering scheme) update p6.n output enable to pin (follows p0.n numbering scheme) 95,97,99,101,103, 105,107,109 capture p6.n input from pin (follows p0.n numbering scheme) update p6.n output to pin (follows p0.n numbering scheme) 110,112,114,116, 118,120,122,124 capture p7.n output enable from mcu (follows p0.n numbering scheme) update p7.n output enable to pin (follows p0.n numbering scheme) 111,113,115,117, 119,121,123,125 capture p7.n input from pin (follows p0.n numbering scheme) update p7.n output to pin (follows p0.n numbering scheme) table 25.1. boundary data register bit definitions (C8051F060/2) extest provides access to both capture and update actions,while sample only performs a capture. bit action target
page 304 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n table 25.2. boundary data register bit definitions (c8051f061/3) extest provides access to both capture and update actions,while sample only performs a capture. bit action target 0capturenotused update not used 1capturenotused update not used 2 capture can rx output enable to pin update can rx output enable to pin 3 capture can rx input from pin update can rx output to pin 4 capture can tx output enable to pin update can tx output enable to pin 5 capture can tx input from pin update can tx output to pin 6 capture external clock from xtal1 pin update not used 7 capture weak pullup enable from mcu update weak pullup enable to port pins 8,10,12,14,16,18, 20,22 capture p0.n output enable from mcu (e.g. bit 8 = p0.0,bit 10 = p0.1,etc.) update p0.n output enable to pin (e.g. bit 8 = p0.0oe,bit 10 = p0.1oe,etc.) 9,11,13,15,17,19, 21,23 capture p0.n input from pin (e.g. bit 9 = p0.0,bit 11 = p0.1,etc.) update p0.n output to pin (e.g. bit 9 = p0.0,bit 11 = p0.1,etc.) 24,26,28,30,32, 34,36,38 capture p1.n output enable from mcu (follows p0.n numbering scheme) update p1.n output enable to pin (follows p0.n numbering scheme) 25,27,29,31,33, 35,37,39 capture p1.n input from pin (follows p0.n numbering scheme) update p1.n output to pin (follows p0.n numbering scheme) 40,42,44,46,48, 50,52,54 capture p2.n output enable from mcu (follows p0.n numbering scheme) update p2.n output enable to pin (follows p0.n numbering scheme) 41,43,45,47,49, 51,53,55 capture p2.n input from pin (follows p0.n numbering scheme) update p2.n output to pin (follows p0.n numbering scheme) 56,58,60,62,64, 66,68,70 capture p3.n output enable from mcu (follows p0.n numbering scheme) update p3.n output enable to pin (follows p0.n numbering scheme) 57,59,61,63,65, 67,69,71 capture p3.n input from pin (follows p0.n numbering scheme) update p3.n output to pin (follows p0.n numbering scheme) 72 capture reset enable from mcu update reset enable to /rst pin 73 capture reset input from /rst pin update not used 74,76,78,80,82,84 capture p5.0,p5.1,p5.2,p5.3,p5.5,p5.7 (respectively) output enable from mcu? update p5.0,p5.1,p5.2,p5.3,p5.5,p5.7 (respectively) output enable to pin? 75,77,79,81,83,85 capture p5.0,p5.1,p5.2,p5.3,p5.5,p5.7 (respectively) input from pin? update p5.0,p5.1,p5.2,p5.3,p5.5,p5.7 (respectively) output to pin? 86,88,90,92,94, 96,98,100 capture p6.n output enable from mcu (follows p0.n numbering scheme)? update p6.n output enable to pin (follows p0.n numbering scheme)?
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 305 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 25.1.1. extest instruction the extest instruction is accessed via the ir. the boundary dr provides control and observability of all the device pins as well as the weak pullup feature. all inputs to on-chip logic are set to logic 1. 25.1.2. sample instruction the sample instruction is accessed via the ir. the boundary dr provides observability and presetting of the scan- path latches. 25.1.3. bypass instruction the bypass instruction is accessed via the ir. it provides access to the standard jtag bypass data register. 25.1.4. idcode instruction the idcode instruction is accessed via the ir. it provides access to the 32-bit device id register. 87,89,91,93,95, 97,99,101 capture p6.n input from pin (follows p0.n numbering scheme)? update p6.n output to pin (follows p0.n numbering scheme)? 102,104,106,108, 110,112,114,116 capture p7.n output enable from mcu (follows p0.n numbering scheme)? update p7.n output enable to pin (follows p0.n numbering scheme)? 103,105,107,109, 111,113,115,117 capture p7.n input from pin (follows p0.n numbering scheme)? update p7.n output to pin (follows p0.n numbering scheme)? ? not connected to pins in this device package. table 25.2. boundary data register bit definitions (c8051f061/3) extest provides access to both capture and update actions,while sample only performs a capture. bit action target figure 25.2. deviceid: jtag device id register version = 0000b part number = 0000 0000 0000 0110b (C8051F060/1/2/3) manufacturer id = 0010 0100 001b (cygnal integrated products) reset value version part number manufacturer id 1 0xn0006243 bit31 bit28 bit27 bit12 bit11 bit1 bit0
page 306 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n 25.2. flash programming commands the flash memory can be programmed directly over the jtag interface using the flash control,flash data,flash address,and flash scale registers. these indirect data registers are accessed via the jtag instruction register. read and write operations on indirect data registers are performed by first setting the appropriate dr address in the ir register. each read or write is then initiated by writing the appropriate indirect operation code (indopcode) to the selected data register. incoming commands to this register have the following format: indopcode: these bit set the operation to perform according to the following table: the poll operation is used to check the busy bit as described below. although a capture-dr is performed,no update-dr is allowed for the poll operation. since updates are disabled,polling can be accomplished by shifting in/ out a single bit. the read operation initiates a read from the register addressed by the draddress. reads can be initiated by shifting only 2 bits into the indirect register. after the read operation is initiated,polling of the busy bit must be performed to determine when the operation is complete. the write operation initiates a write of writedata to the register addressed by draddress. registers of any width up to 18 bits can be written. if the register to be written contains fewer than 18 bits,the data in writedata should be left- justified,i.e. its msb should occupy bit 17 above. this allows shorter registers to be written in fewer jtag clock cycles. for example,an 8-bit register could be written by shifting only 10 bits. after a write is initiated,the busy bit should be polled to determine when the next operation can be initiated. the contents of the instruction register should not be altered while either a read or write operation is busy. outgoing data from the indirect data register has the following format: the busy bit indicates that the current operation is not complete. it goes high when an operation is initiated and returns low when complete. read and write commands are ignored while busy is high. in fact,if polling for busy to be low will be followed by another read or write operation,jtag writes of the next operation can be made while checking for busy to be low. they will be ignored until busy is read low,at which time the new operation will ini- tiate. this bit is placed at bit 0 to allow polling by single-bit shifts. when waiting for a read to complete and busy is 0,the following 18 bits can be shifted out to obtain the resulting data. readdata is always right-justified. this allows registers shorter than 18 bits to be read using a reduced number of shifts. for example,the results from a byte-read requires 9 bit shifts (busy + 8 bits). 19:18 17:0 indopcode writedata indopcode operation 0x poll 10 read 11 write 19 18:1 0 0 readdata busy
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 307 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information figure 25.3. flashcon: jtag flash control register this register determines how the flash interface logic will respond to reads and writes to the flashdat register. bits7-4: wrmd3-0: write mode select bits. the write mode select bits control how the interface logic responds to writes to the flashdat register per the following values: 0000: a flashdat write replaces the data in the flashdat register,but is otherwise ignored. 0001: a flashdat write initiates a write of flashdat into the memory address by the flashadr register. flashadr is incremented by one when complete. 0010: a flashdat write initiates an erasure (sets all bytes to 0xff) of the flash page containing the address in flashadr. the data written must be 0xa5 for the erase to occur. flashadr is not affected. if flashadr = 0x7bfe - 0x7bff,the entire user space will be erased (i.e. entire flash memory except for reserved area 0x7c00 - 0x7fff). (all other values for wrmd3-0 are reserved.) bits3-0: rdmd3-0: read mode select bits. the read mode select bits control how the interface logic responds to reads to the flashdat reg- ister per the following values: 0000: a flashdat read provides the data in the flashdat register,but is otherwise ignored. 0001: a flashdat read initiates a read of the byte addressed by the flashadr register if no operation is currently active. this mode is used for block reads. 0010: a flashdat read initiates a read of the byte addressed by flashadr only if no operation is active and any data from a previous read has already been read from flashdat. this mode allows single bytes to be read (or the last byte of a block) without initiating an extra read. (all other values for rdmd3-0 are reserved.) reset value wrmd3 wrmd2 wrmd1 wrmd0 rdmd3 rdmd2 rdmd1 rdmd0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
page 308 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n figure 25.4. flashdat: jtag flash data register this register is used to read or write data to the flash memory across the jtag interface. bits9-2: data7-0: flash data byte. bit1: fail: flash fail bit. 0: previous flash memory operation was successful. 1: previous flash memory operation failed. usually indicates the associated memory location was locked. bit0: busy:flashbusybit. 0: flash interface logic is not busy. 1: flash interface logic is processing a request. reads or writes while busy = 1 will not initiate another operation reset value 0000000000 bit9 bit0 figure 25.5. flashadr: jtag flash address register this register holds the address for all jtag flash read,write,and erase operations. this register autoincrements after each read or write,regardless of whether the operation succeeded or failed. bits15-0: flash operation 16-bit address. reset value 0x0000 bit15 bit0
? 2002 cygnal integrated products, inc. ds007-0.4-nov02 page 309 C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n advanced information 25.3. debug support each mcu has on-chip jtag and debug logic that provides non-intrusive,full speed,in-circuit debug support using the production part installed in the end application,via the four pin jtag i/f. cygnal's debug system supports inspec- tion and modification of memory and registers,breakpoints,and single stepping. no additional target ram,program memory,or communications channels are required. all the digital and analog peripherals are functional and work correctly (remain synchronized) while debugging. the watchdog timer (wdt) is disabled when the mcu is halted during single stepping or at a breakpoint. the C8051F060dk is a development kit with all the hardware and software necessary to develop application code and perform in-circuit debug with each mcu in the c8051f06x family. each kit includes an integrated development environment (ide) which has a debugger and integrated 8051 assembler. the kit also includes an rs-232 to jtag interface module referred to as the serial adapter. there is also a target application board with a C8051F060 installed. rs-232 and jtag cables and wall-mount power supply are also included.
page 310 ds007-0.4-nov02 ? 2002 cygnal integrated products, inc. advanced information C8051F060/1/2/3 a d v a n c e d i n f o r m a t i o n disclaimers life support : these products are not designed for use in life support appliances or systems where malfunction of these products can reasonably be expected to result in personal injury. cygnal integrated products customers using or selling these products for use in such applications do so at their own risk and agree to fully indemnify cygnal inte- grated products for any damages resulting from such applications. right to make changes : cygnal integrated products reserves the right to make changes,without notice,in the prod- ucts,including circuits and/or software,described or contained herein in order to improve design and/or performance. cygnal integrated products assumes no responsibility or liability for the use of any of these products,conveys no license or title under any patent,copyright,or mask work right to these products,and makes no representations or warranties that these products are free from patent,copyright,or mask work infringement,unless otherwise specified. cygnal integrated products 4301 westbank drive suite b-100 austin, tx 78746 www.cygnal.com cip-51 is a trademark of cygnal integrated products,inc. mcs-51 and smbus are trademarks of intel corporation. spi is a trademark of motorola,inc. i 2 c is a trademark of philips semiconductor.


▲Up To Search▲   

 
Price & Availability of C8051F060

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X